Player sprite flip

Whenever I put this code into Godot
if direction.x == -1:
get_node(“AnimatedSprite2D”).flip_h = true
get_node(“AnimatedSprite2D”).flip_h = false
It says “Invalid set index ‘flip_h’ (on base: ‘null instance’) with value type ‘bool’”.
How do we solve this issue?
my scene tree is

Collision shape 2D
Animated sprite 2D
Animation Player

meaning your animated sprite 2d is not located
show your scene tree

@zdrmlpzdrmlp it’s up there now

these 3 nodes are inside the player main node?
the script is attached to the player main node?

there is a script attached to the main node, that is where I’m putting the code in and having the issue

that is how it is typed out in the string but I was having that issue beforehand

this should be a really simple error, probably like a typo joyfulsquirrel mentioned
other than get_node(), you can also try to drag and drop the node from scene tree to code directly, there should be no typo by that

ok i will try that

still showing the same error

i hope you dont put the drag and drop inside the get_node(), because it will not work like that

oh… ok

it was because it doesn’t go by the program name but the assigned one so it thought that “AnimatedSprite2D” didn’t exist because it was called “Animations”.
and thanks for the help