I recall somewhere I read that any signal connections done from a script will disconnect when the script is destroyed. Is this true? Is it true for all signal connections, i.e. on BindableEvents or Instances external to the script?
If I require a module and run a function which creates a script connection, will that connection disconnect on destruction of the original script what required the module?
When a script or thread that creates a script connection is deleted via :Destroy or the thread is closed, the connection will be disconnected as well.
Scripts cache the modulescript they require, so all it’s doing is storing the modulescript’s data. So, anything you do in that script is still “owned” by the thread it creates, which is closed when the script is destroyed or stops running.
To clarify- it doesn’t apply to coroutines because they don’t actually generate their own thread. They just run in parallel to the one it was created in. So script connections you connect in a coroutine will still need to be disconnected before the coroutine is closed or yielded.
Does task.spawn() return a new thread which can clean up its connections? Im reading the docs and it says it returns the scheduled thread but now I am confused because I thought task.spawn() and coroutine.create() were pretty much the same.