RBXScriptSignal Questions

Roblox has functions to manually disconnect events with the :Disconnect function, however there are conditions where it happens automatically, below are me wondering if it is automatic

1. Does CharacterAdded automatically disconnect when a player leaves I redacted this one because it’s obvious

  1. Does disabling a script automatically disconnect events
  2. Do module scripts rebind events every time they are required or does it only create the event once
  3. Destroy() disconnects events but do unreferenced objects parented to nil automatically get their events disconnected then removed by the GC

Thanks

IIRC I did some testing a few months ago which showed that when you disable a script, its event handlers are “paused” and are “resumed” when you re-enable the script. This could’ve changed since then though.

A ModuleScript’s code runs only once ever - the first time it’s required. Its return value is cached, so when you require it again, it returns the same value but does not re-run.

As for the last one, I have no idea. Roblox’s instances gc’ing can be really weird sometimes (which is why your 1st point isn’t actually obvious).

For the last one, no unreferenced objects parented to nil automatically do not get their connections disconnected because that is literally the key difference between :Remove() and :Destroy()
While :Remove() sets the parent of an object to nil, the :Destroy() function disconnects any connections to the object, locks its parent property, and calls :Destroy() on all of it’s descendants

1 Like