Error : Attempt to call function 'play' in base 'null instance' on a null instance

Godot Version

4.2.2

Question

Hi very new to programming and Godot in general, my animation used to work, but now it doesnt. To be honest I have no idea what happenened. I tried to add a coin using Animatedsprite2D on a different scene before it happened, I changed both of their names respectively to AnimatedPlayer2D (for the player) and AnimatedTennis2D( for the coins) The animation is in godot and the “kickflip” input is in the project settings, yet every single other animations work just fine and are written the same way.

If the information I gave is not sufficient please let me know. Oh and I forgot, please explain to me like Im five. I dont know alot yet.

Any help would be really appreciated :slight_smile:

The line that gives me the error is : $AnimatedPlayer2D.play(“dog_heelflip”)

Heres my code :

if Input.is_action_just_pressed("kickflip") and is_airborne:
		$AnimatedPlayer2D.play("dog_heelflip")

Maybe the “$AnimatedPlayer2D” moved, or changed name. The error states it did not find an animated player for which to play.

Do you mean moved in the scene tree ? Everything seems at the right place, but I did change its name in the scene tree and my script. Do I have to change it somewhere else ?

If your other animations are working then you should look to those, how are you playing animations that are not “dog_heelflip”?

In the same way, the only difference is the “is_airborne”. By getting the node $AnimatedPlayer2D then .play(“animation_name”). Thanks for helping btw !