Seems the issue is that pause
is not being set correctly. What does your scene tree look like?
The onready var pause = find_node("Player/HUD/pause")
code is not finding the pause node, so the variable is being set to null, which is causing the error.
Here is what I would do: use an exported NodePath so that you can set the path to the pause
node from the Godot editor. I've written the modifications needed below:
Replace line 6, onready var pause = find_node("Player/HUD/pause")
, with the following:
export (NodePath) var path_to_pause_node = null
var pause_node = null
Then add the following to _ready
:
func _ready():
if path_to_pause_node != null:
pause_node = get_node(path_to_pause_node)
else:
print (name, " does not have pause node setup in the Godot editor!")
Finally, change _on_timeout_complete
to the following:
func _on_timeout_complete():
pause_node.show()
# or
# pause_node._on_btn_pause_released()
Then all you need to do is select the Player node with this script in the Godot editor, and point the node path to the node with the pause script, and then it should work.