All instances of a scene disappearing at once

Godot Version

version 4.7

Question

Hi! I’m very new to Godot. I’m coding a game where you can press a button to add many different versions of a ‘guy’ scene. Each of the instances of the guy scene carry a ‘cargo’ scene, which scores points when it hits a specific spot, then disappears with ‘queue_free()’

My issue is that when one of the guy instances hits that spot, all of the cargo instances disappear, not just the one that hit the spot. How do I stop this from happening?

Here is the code to spawn the guy into the game scene:


func spawn_guy() -> void:
	var _spawned_guy = LITTLE_GUY.instantiate()
	_spawned_guy.position = Vector2(10, 300)
	add_child(_spawned_guy)

This is the code that spawns the cargo scene into the guy scene:


func spawn_cargo() -> void:
	var new_cargo: Cargo = CARGO.instantiate()
	new_cargo.global_position = Vector2(59, 0)
	add_child(new_cargo)

Any help would be appreciated. Thanks!

Can you show how you’ve hooked up the queue_free part of the code?

I managed to fix it by detecting what body entered the area before removing it.