Attempt to call function 'stop' in base 'null instance' on a null instance.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gogi

extends AnimatedSprite

func _process(delta):
if Input.is_action_pressed(“ui_right”):

The error is : Attempt to call function ‘stop’ in base ‘null instance’ on a null instance.
Please help me

:bust_in_silhouette: Reply From: kidscancode

$AnimatedSprite means “get a node called ‘AnimatedSprite’ that’s a child of this one”.

Since your script starts with extends AnimatedSprite, it appears that this script is attached to the animated sprite, not the parent of one.

If that’s the case, then you can just call play() and stop() without getting any node.