How can i make the player play a death animation upon death?

Godot Version

4.3

Question

Hello! I'm pretty new to Godot and I'm trying to make a simple 2D Platformer game! I decided to follow a tutorial by Brackeys to help set up the enemies and and respawn system. It was going smooth-sailing until I decided I'd like to implement a death animation. For a reason I can't identify, it wont work and I've been trying for hours. For context, I'm using an AnimatedSprite2D and the death animation is called "die". I've tried adding a 'hurtbox'Area2D to my player that plays the animation when it detects the enemy but it didn’t work. The enemy is a Node2D but I’m using an Area2D within that called “killzone” to handle death. No matter how hard I try, I can’t seem to get this animation to play. Below I’ll paste my scripts; please let me know if I’m being silly and not doing something obvious. Also I apologise that they’re images and not the direct code, I couldn’t paste it properly and it was even more confusing.

Player Script:

Killzone:


If you need anything else from me, ask away!

Any help would be greatly appreciated, thank you in advance!

Try adding print() statements into your code to understand what triggers and what doesn’t trigger. It’s the easiest way to debug issues.

Also, please don’t post screenshots of your code, but paste the code directly and format it properly. See Posting guidelines in #Help channel. It makes it way easier for us to help you.

thank you! I really don’t use those enough and they come in super handy!

Also I apologise for the screenshots; it’s my first time making a post here and when i tried to paste my code, only some of it would paste properly and other parts would just appear as normal text. I’ll make sure to paste it properly next time though.