0 votes
                   ready var player = get_node("AnimatedSprite")

    if get_global_mouse_position().y > 414 :
        if get_global_mouse_position().y < 494 :
            if Input.is_action_just_pressed("die"): 
                var mouseps = get_global_mouse_position()
                player.play("teleport")
                yield(player,"animation_finished")
                self.position = mouseps
                player.play("Idle")

error = Attempt to call function 'play' in base 'null instance' on a null instance

i don't know what i've done but before adding it to autoload it was working

in Engine by (12 points)

1 Answer

0 votes

Well, player is not initialized. This means that the node "AnimatedSprite" is either not found as direct child of the node where you attached that script or the first line (is it "onready"?) is actually initialized after the code below is called.

Make sure that the code gets executed after player is initialized. For example "onready" global variable initializers are actually set only after the _ready() handler is done.

So if that code is is executed inside _ready() then assign the variable right before (indenting is broken so I think that variable was declared/set elsewhere?) it. And make sure that your player node is actually found inside that script.

by (3,258 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.