Connect Parent signal to every instanced child (Solved)

Godot Version



Hi! Having trouble getting a parent’s signal to connect to instanced child scenes, not sure where I’m going wrong.

Here’s a simplified version of what I’m trying to do. The goal is to have the “jump” signal trigger the “jump” function on each instance of the “person” scene

signal jump
var person = preload("res://Scenes/person.tscn")

func _ready():

func addPerson():
	var crowdMember = person.instantiate()

	# Here is the code that is not working

func _process(delta):
	if Input.is_action_just_pressed("Jump"):

Child script (In this case, the “Person”)

func on_jump():
	print("I Jumped!")

Super simplified version of what I’m trying to do, but every time the “Jump” action is pressed, it should trigger the function inside the child. However, the attempt to create the connection creates the following error message:

Invalid type in function 'connect' in base 'Node2D ('. Cannot convert argument 2 from Nil to Callable.

Why does the function return as a Nil?

The second argument from connection method is null. In Godot 4, you usually connects a signal using a Callable. So, in your case, this might work:
connect("jump", Callable(crowdMember, "on_jump"))

1 Like

crowdMember.on_jump() is a call so the on_jump function will be executed once and return null.
Just change it to connect("jump",crowdMember.on_jump). Then you connect the reference to the callable and not the result of the execution. Should do it.

1 Like

Replace this:

With this:

1 Like

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