sending signals from an instanced scene

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

Hi, I have a scene for a fishing minigame that I load up as an instance on the canvas layer. After the player is finished playing the minigame I want to have a signal that returns the players movement to them however I don’t know how to connect a signal from an instanced scene, how can I detect if the window is closed or connect a script from the instanced scene to my player when it’s not in the world tree?

:bust_in_silhouette: Reply From: klaas

Hi,
when you instance a scene it gets inserted in the tree via add_child(). So, you instanced scene is in the tree.
You can connect to this instance with:

var _i = load("my_scene.tscn")
var inst = _i.instance()
add_Child(i) #add as child of this node

 #connect this object to a signal of the instance and do something on this object with ...
inst.connect("signalname",self,"do_something")

#or

 #connect the instance to a signal of this object and do something on the instance ...
connect("signalname",inst,"do_something")