Invalid call. Nonexistent function 'hide' in base 'PackedScene'

Godot Version

v. 4.2.1

Question

Hello. I’m having problems with the pause menu. When i run the project, i get an error:

Invalid call. Nonexistent function ‘hide’ in base ‘PackedScene’

Here’s the code:

extends Node

@onready var pause_menu = load(“res://Scenes/UI/pause_menu.tscn”)

var game_paused: bool = false

func _process(_delta):
if Input.is_action_just_pressed(“ui_cancel”):
game_paused = !game_paused

if game_paused == true:
get_tree().paused = true
pause_menu.show()
else:
get_tree().paused = false
pause_menu.hide()

func _on_resume_pressed():
game_paused = !game_paused

func _on_exit_pressed():
get_tree().paused = false
get_tree().change_scene_to_file(“res://Scenes/UI/main_menu.tscn”)

What’s the problem? Thanks in advance!

You need to instance it, you are calling in the resource, not the node, see here

2 Likes

Thanks!

1 Like