Player is null and i don´t know why

Godot Version

4.3

Question

“Hello, I am currently working on a save and load script. The problem is that the player is still found in the save function, but in the load function, it is null. Does anyone have an idea why?”

Unique names are not for getting a truely unique node, they are quite limited and inteded to shorten node paths within the same scene. Since your global does not have a %Player in the editor, it will not find a %Player

1 Like

how can i fix it

The problem is line 40, you’re using the get_node method but giving it the path to a resource, not a node. Just deleting that line might work if you already have a player object in the scene tree and are just updating it in the load_game function.

If you need to add a fresh player instance, change get_node to load (or preload might even work), instantiate it, use add_child to add the node to the scene tree, and connect any signals involving the player. Although if there was already an existing player node at that point things will be more complicated.

Docs on adding new nodes from scene files:

2 Likes