Unable to connect a signal to anything

Godot Version

4.4.1

Question

I’ve got a global scene with a signal in it signal game_start. This signal returns an error whenever I connect it to something, specifically Invalid type in function 'connect' in base 'Signal'. Cannot convert argument 1 from Nil to Callable.

Here is the code:

signal game_start

func _ready():
	game_start.connect(_on_game_start())

func _on_game_start():
	print("game start! Global call")

game_start is being called by another scene, but I get this error before I even emit the signal. Unsure of why this is happening considering I’ve made other signals in the past with no issue in the same way.
I also tried connecting it via the Node window but that just plain doesn’t work. It says its connected and everything but doesn’t actually work when the signal is emitted

since _on_game_start() ends with parenthesis you are telling Godot to call the function _on_game_start, so it will print “game start! Global call” and try to connect what ever the function returns, which is nothing (Nil).

If you remove the parenthesis you are connecting the function instead of using it right then.

signal game_start

func _ready():
	game_start.connect(_on_game_start)

func _on_game_start():
	print("game start! Global call")
1 Like

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