Referencing nodes in GDScript

Godot Version

4.2.2

Question

This is probably a real noob question but it’s driving me mad. In all the tutorials when a node, say ‘Player’ is dragged into the code (GDScript) it appears as $Player but when I do it, it appears as $(“/…/Player”). Why? I know $ is short for ‘get_node’ but why the relative path?

My tree looks like:

Level

Platform
Player (instance)
Enemies

$ looks for children, .. goes up one parent. Their script is probably attached to the Level node, where yours could be on Platform or Enemies, or that scene is open and selected.

You could also use @export to select the instance from the inspector, I find it easier and godot will update the path for you when move children around.