Game opens in godot start menu, but not in editor

Godot Version

v4.3.stable.arch_linux

Question

I’m new at godot and I have a problem in a game that i’m making.

I had this piece of code that worked from when I started the project until a while ago

func _ready() → void:

$"../Main_menu".show() 
$"../Play_menu".hide()
$"../Player_select".hide()

But now it doesn’t work. I don’t know what broke it. When I press the play button it gives me this error instantly marking those 3 lines.

  • Attempt to call function ‘show’ in base ‘null instance’ on a null instance.

But when I press play in the godot projects menu it actually works normally.

If you see a null or nil instance in an error, it means the following:
The variable or object just before the method (in the same error) doesnt exist.

This means that you either moved or renamed the nodes in your scene and did not update the names in your code.

So I would recommend using @export instead of using the tutorial way with $"something/something".

Your new code would be something like:

@export var main_menu : type
@export var play_menu : type
@export var player_select : type

func _ready() -> void:
    main_menu.show() 
    play_menu.hide()
    player_select.hide()

Dont forget to replace type with the correct node type that you used for these.

1 Like