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 dk dk

extends Area2D

export var speed = 100
var screen_size
signal pontua2

func _ready():
screen_size = get_viewport_rect().size

func _process(delta):
var velocity =Vector2()
if Input.is_action_pressed(“descer”):
velocity.y += 1
if Input.is_action_pressed(“sobe”):
velocity.y -= 1
if velocity.length() > 0:
velocity = velocity.normalized() * speed
$galinha2.play()
else:
$galinha2.stop()
position += velocity * delta

position.y = clamp(position.y,0,screen_size.y)

if velocity.y > 0:
	$galinha.animation = "baixo"
elif velocity.x < 0:
	$galinha.animation = "cima"

func _on_player_body_entered(body):
if body.name == “ganha”:
emit_signal(“pontua2”)
else:
$“audio de colisao”.play()
position.x = 944
position.y = 696

:bust_in_silhouette: Reply From: Wakatta

Your problem is probably the most common for beginners as seen
here, here, here and here

Generally it means you tried to use the reference of a node that no longer exists, that doesn’t exists or your NodePath to it is spelled or located incorrectly