ummm im trying to flip the player but getting this error
![]()
and this is my code
![]()
so how can i fix this?
Make sure the node is actually called AnimatedSprite2D in your scene. It looks like it’s not called that.
node type or node name?
Literally the node name, when using $"NodeName" on anything, it expects a node named exactly that within the scene tree it is called on, if it is even a single char off, it will throw an error, if it is the same, but in a different level, e.g. up one level, down one, then you will have to take the node path with either $"../NodeName", or $Child/Nodename, the node type doesnt matter to “$”,
Note, the names i provided are placeholders, they wont work unless they match your scene tree.
still not working
Can you show a screenshot of your scene tree where this script is attached?
Well, first of all, you were (or still are, as i cannot see your code) trying to find a node literally called $AnimatedSprite2D, since you showed your scene tree akin to @tibaverus’s request, I assume you are trying to access the Player animated sprite 2d, and with that in mind, the correct structure would literally be $"Sword/Player",
nevertheless, i dont think your system is very well structured, now, i cant exactly be for certain, but depending on your actual intentions, it might be a better idea to use a different structure altogether, may i ask, what is it you are attempting to accomplish?
its because you put $animatedSprite2D instead of what the name is which is Player(you should just drag it to the code, just in case something is different than just the name). The name in the node tree is called player. tell me if that fixes it. Also, I would change the name of the animatedSprite2D to something like player animation to tell the difference. Also, is the animated sprite 2d supposed to be a child of sword?
okay that fixed the problem but another error im getting is this
![]()
![]()
Try rewriting your get_nodes to get_node(“Sword/AnimationPlayer”)
See if that makes the error go away.
Like everyone else is saying, some functions look at the name of the object in your scene tree, which you can name anything. Make sure you are telling the computer to look for that same exact name
Yeah, what @Josh_W said, you can also drag nodes into the script editor.
the error is in the get_animation(“slash”)
never mind it worked
No, the error is “…base ‘null instance’ on a null instance”.
A “null instance” is basically something that doesn’t exist. You told the computer to look for a node named “Sprite” in your Player scene tree, but nothing in that scene tree is named “Sprite”. Therefore, an object named “Sprite” is a “null instance”, which the computer cannot use.
The tricky part is this: You gave your Player a child node of the class Sprite2D. Then you changed its original name “Sprite2D” to “Sword”. Your “Sword” is still the class Sprite2D, but it’s name is “Sword”.
Again, when you use certain functions that look for names, you have to give the computer the right name to look for.
ye its solved