Pause menu crashes game when made a child of canvas layer

Godot Version

Godot v4.2.1

Question

Added a pause menu but it doesn’t follow the character/camera, every time I try to move it to be a child of the canvas layer, it crashes the game every time I try to pause. It says “Attempt to call function ‘show’ in base ‘null instance’ on a null instance” How can I fix that?
Below are the code I’ve used + error code. Thanks in advance

pause_menu is null when you call show()

the line 18 is correct?

where is this script? on Game or Pause Menu?
image

edit-

crashes game when made a child of canvas layer

Okay, I think I see it, you have it in Game. After making it a child of canvas layer you must also update its reference

$PauseMenu
can’t find it because now you have it in
$CanvasLayer/PauseMenu

1 Like

Changed line 18 to ‘$CanvasLayer/PauseMenu’ and it works now. Thank so much for your help.

burn the error into your brain

in base ‘null instance’ on a null instance

in this case was “show()” calling to the void and finding nothing, that’s why the error and it will happen to you many times

null instance’ on a null instance

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.