Invalid type in function 'connect' in base 'Signal'. Cannot convert argument 1 from Nil to Callable

Godot Version

4.2

Question

im following Heartbeast’s action rpg tutorial part 22.
connect() is different in gd4 so i had to come up with a solution of my own and i dont think i succeeded.

extends AudioStreamPlayer

@onready var playerhurtsound = $"."

func _ready():
	playerhurtsound.finished.connect(definitely_not_queue_free())

## making this function fixed the error in the editor but not in game. probably because it kills this scene
## rather than responding to a scene being killed or something like that.
func definitely_not_queue_free():
	print("help me") 
	queue_free()
	

it spat out the error message Invalid type in function 'connect' in base 'Signal'. Cannot convert argument 1 from Nil to Callable.
im so sorry if this question may sound stupid, i’am genuinely just stuck

Remove the “()” after the function name inside connect.

I shall sugest to use the full aprouch.

playerhurtsound.connect(“finished”,Callable(self,“definitely_not_queue_free”))

worked! thank you!

1 Like