Help with connecting signals for pause menu

I am new to Godot. I’m trying to make a pause menu but connecting a signal of the “resume” button isn’t working. I press the button and it doesn’t work. I’m connecting the signal within the code because the pause menu is a scene itself.

extends Node

var mouselocked = true

@onready var pausemenu: Control = get_tree().current_scene.get_node("CanvasLayer/PAUSE MENU")
@onready var resumebutton: Button  = pausemenu.get_node("CenterContainer/PanelContainer/VBoxContainer/resume")
@onready var quitbutton: Button = pausemenu.get_node("CenterContainer/PanelContainer/VBoxContainer/quit")

func _onready():
	resumebutton.button_up.connect(Callable(self, "_resumed"))

func togglepause():
	if mouselocked == true:
		mouselocked = false
		Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
		get_tree().paused = true
		pausemenu.visible = true
	else:
		mouselocked = true
		Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
		get_tree().paused = false
		pausemenu.visible = false

func _input(event):
	if event.is_action_pressed("ui_cancel"):
		togglepause()

func _resumed():
	if mouselocked == false:
		togglepause()

1 Like

Is your resume button paused? Did you set it’s (or the PAUSE MENU’s) process mode to “Always” or “When Paused”

_onready isn’t an override, but _ready is, maybe you need to change to the latter. As a side note you can use the method name as it’s already a Callable

func _ready() -> void:
	resumebutton.pressed.connect(_resumed)

This is pretty crazy, why not attach this script to the Pause menu? Or use @exports instead?

Man I keep confusing @onready and _ready. Also, what does @export do?

You should rely more on autocompletion that Godot Editor offers. When writing func _onready() there is no autocompletion - that should be a red flag for you that maybe you typed something wrong.
image

When writing func _ready() there is autocompletion, confirming that such a function exists.
image

You can find more info here:

1 Like