About connections and deleting it

Do garbage collection destroy connections? Also, just for later, how do you destroy connections of an object without a reference to the actual connection? I want to learn so my game doesn’t become 1 gig after five minutes

GC removes all things that have no reference (or weak reference) to it somewhere. That means, if you set a variable that contains the only reference to a table to nil, the table will be garabage collected. Calling :Destroy() on an instance will automatically disconnect all connections.

Read more about it here.

You can’t do that, you can only disconnect connections if you have the RBXScriptConnection returned from :Connect().

1 Like

Note: you can only destroy roblox script connections by

  • declaring a variable that references the connection and then doing :Disconnect()
  • Destroying the object that the script connection belongs to.
2 Likes

Is that in order, or are both possibilities ?

They’re both possibilities. You can do either one of them.

1 Like

i’ll make it an unordered list so it makes more sense in the future.