Signal Does Not Emit

Godot Version

4.2.1

Question

I have 3 signals, 2 of which work completely fine, but the third one does not work properly

extends Node

var score: int
var difficulty: float = 1
var is_game_over: bool = false

signal update_score(value)
signal player_died(value)
signal restart_game()

func increase_score():
	score += 1
	difficulty += 0.03
	update_score.emit(score)

func game_over():
	#-- Print Text
	print("GAME OVER \nYou obtained ", score, " Points")
	
	#-- Emit signal
	player_died.emit(score)
	
	#-- Reset Variables
	score = 0
	difficulty = 1
	is_game_over = true

func _on_restart_button_button_down() -> void:
	restart_game.emit()
	print("Telling game to restart...")

This is the GameManager script, where the signal is declared and emitted.

extends CanvasLayer

#-- Variables
var score_text: Label
var death_panel: Panel
var death_score: Label
var death_title: Label
var restart_button: Button

func _ready() -> void:
	#-- Variable Setup
	#---- Score Text
	score_text = $ScorePanel/ScoreText
	#---- Death Screen
	death_panel = $DeathPanel
	death_score = $DeathPanel/FinalScoreText
	death_title = $DeathPanel/DeathTitle
	restart_button = $DeathPanel/RestartButton
	#-- Connect signals
	GameManager.connect("restart_game", _on_restart)
	GameManager.connect("update_score", _on_update_score)
	GameManager.connect("player_died", _on_gameOver)

func _on_update_score(new_score): 
	score_text.text = str(new_score)
	# Works!

func _on_gameOver(final_score):
	death_panel.visible = true
	death_score.text = "FINAL SCORE | " + str(final_score)
	# Works!

func _on_restart():
	death_panel.visible = false
	print("Restarting")
	# Doesn't Work!

This is the ui canvas script, where the signal that doesn’t work is emitted to (The signal that doesn’t work is “restart_game”)

Don’t think you need the brackets here [as] you have no args. That said, your signal is in response to _on_restart_button_button_down, which the post doesn’t show how this is triggered; assuming it would be connected via the editor, it’d be helpful to show your working.

Perhaps even via a small reproducible test case as this is fairly trivial overall and unlikely to be failing without some minor config. issue.

  1. I tried removing the brackets, that didn’t change anything
  2. _on_restart_button_button_down is activated via clicking a button

Is there anything else you need to know?

Does the following

print("Telling game to restart...")

Print to the console? This would confirm that the event was triggered.

Does

print("Restarting")

Print to console?

Can you make something that looks like this with all the appropriate Inspector functions.
jd5
jd6
jd7

Then maybe we can discuss trying this.

Game Manager

extends Node
var score = 0
var difficulty = 1
var is_game_over = false
signal update_score
signal player_died

func increase_score(): # Must be called at some point, like killing an enemy
	score += 1
	difficulty += 0.03
	update_score.emit()
	print(score) # This will print the score as it increases

func game_over():
	print("GAME OVER") # This is output
	print("You obtained " + str(score) + " Points") # This is just the next line of the output
	player_died.emit()
	# Everything below must happen last because it effects content above
	score = 0
	difficulty = 1
	is_game_over = true

func _unhandled_input(event):
	if event is InputEventKey:
		if event.pressed and event.keycode == KEY_ESCAPE:
			game_over()

User Interact

extends CanvasLayer

func _on_game_manager_update_score():
	$ScorePanel/ScoreText.text = str(get_parent().score) # This will simply pillage the village and eventually it will do what it must

func _on_game_manager_player_died():
	$DeathPanel.show()
	$DeathPanel/DeathTitle.text = "FINAL SCORE " + str(get_parent().score)

func _on_restart_button_pressed():
	$DeathPanel.hide()
	print("Restarding")
	get_parent().is_game_over = false

You can just double click or right click for more option. On signals in the inspector. To bring up the node window. Select whatever you like. Click connect. The code is automatic like that. With #pass
jd8

You can also make more functions and variables to fill more signals. As long as they have their uses.
There is a commemorating amount of speculation you can only use 1 Script per code. Not true. If you were to extend a script. The predefined extension is provided. All you can do is use it. Just save it as you progress your scripts.
All of this works. As long as it has an article to extend to. Right now you can get prints.


And, once more make sure your structure is correct.

jd11

So you can extend your current and extended code.
Game Manager

extends Node
var score = 0
var difficulty = 1
var is_game_over = false
var play_allowed = false
signal update_score
signal player_died
signal defend
signal damage

func increase_score(): # Must be called at some point, like killing an enemy
	score += 1
	difficulty += 0.03
	update_score.emit()
	print(score) # This will print the score as it increases

func game_over():
	print("GAME OVER") # This is output
	print("You obtained " + str(score) + " Points") # This is just the next line of the output
	if play_allowed: # Can be inserted anywhere, with proportional function block
		player_died.emit()
		play_allowed = false # Will revert to normals
	# Everything below must happen last because it effects content above
	score = 0
	difficulty = 1
	is_game_over = true

func _unhandled_input(event):
	if event is InputEventKey:
		if event.pressed and event.keycode == KEY_ESCAPE:
			game_over()

func play():
	play_allowed = true

func go_defend():
	defend.emit()

func treated_as_enemy():
	print("You are getting attacked!")
	print("At the minimum " + str(score) + " !")	

func take_damage():
	damage.emit()

game cleric

extends "res://GameManager.gd"

signal threat
signal factorial
signal deterent
var allowed = false
var shred = true

func _on_player_died(): # This is the active passthrough field
	if allowed == true:
		play()

func _on_threat():
	treated_as_enemy() # This is an extra function to declare attack

func _on_deterent():
	print("Marker change.") # This is an extra function to declare defense

func _on_defend():
	threat.emit()
	deterent.emit()

func _on_damage():
	if shred:
		print("Do you allow?" )
		shred = false
		factorial.emit()

func _on_factorial():
	shred = true

User Interact

extends CanvasLayer

func _on_game_manager_update_score():
	$ScorePanel/ScoreText.text = str(get_parent().score) # This will simply pillage the village and eventually it will do what it must

func _on_game_manager_player_died():
	$DeathPanel.show()
	$DeathPanel/DeathTitle.text = "FINAL SCORE " + str(get_parent().score)

func _on_restart_button_pressed():
	$DeathPanel.hide()
	print("Restarding")
	get_parent().is_game_over = false