how do i spawn a node with signals connected?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By tonykkjk

I’m making a game with Enemies, but every time i spawn a new enemy, that enemy doesn’t react to the signals, because hes from another root scene, so how i can connect them between scenes?

:bust_in_silhouette: Reply From: Wakatta

If that enemy has his own script

# Connect the signals
func _enter_tree():
    connect ("onDeath", current_scene, "_enemy_died")

# Disconnect all signals
func _exit_tree():
    disconnect ("onDeath", current_scene, "_enemy_died")