How to emit signal to multiple instances of same scene?

Godot Version

4.7.2

Question

I got one level - within there is two crates, one lever.

Lever acts as emitter to send signal to crate to remove itself on pull.

Level Scene_Tree

Signal from Lever in connected to Exploding Crate but it removes only one of the Crates.

relevant logic from lever code

func _input(event: InputEvent) -> void:
	if Input.is_action_just_pressed("player_1_interact") and player_1_is_in_range:
		if toggled:
			animation_player.play("toggle-off")
			toggled = false
		else:
			animation_player.play("toggle-on")
			toggled = true
			emit_signal('lever_pulled')
			print("signal emitted")

This emits multiple times, so it’s working.

Crate got this small code, and this is where it only receive signal once.

extends Node3D
var crate := self
func _on_lever_lever_pulled() -> void:
	print('signal came')
	crate.queue_free()

Check that both crates properly connect to the signal.

When I connected it from Inspector it shown as connected, but it affected only one instance.

I tried code connection instead and that worked

extends Node3D
var crate := self
@export var lever: Node3D

func _ready() → void:
lever.lever_pulled.connect(_on_lever_lever_pulled)

func _on_lever_lever_pulled() → void:
print(‘signal came’)
crate.queue_free()

Let’s see the connections.

Both share same script

Oh, I got it :slight_smile: it not apply automatically to both need to separately click it

My mistake, for each instance need to click signal again and connect it again :slight_smile:

Yes, connect to each instance in the main scene. Don’t connect from within the scene to signals that are outside.