When a player leaves the place, do all connections attached directly to the player get disconnected?

ex:

Players.PlayerAdded:connect(function(p)
     p.ChildAdded:connect(function() -- connection get disconnected

     end)
end)

Does the ChildAdded event get disconnected? If not, there’s a lot of memory leaks left for me to fix.

I believe so, yes. When a player is removed, it should act like :Destroy(), which disconnects all events.

Doesn’t Roblox internally :remove() or nil the parent the player object when left?

Roblox SHOULD be internally using :Destroy(), which would have those same effects and then some.

You can test this by storing the Connection in a variable. The connect method always returns the connection, which has a method for disconnecting, as well as a property which tells you whether or not it’s been disconnected already.

3 Likes