Do I need to disconnect events that were on destroyed instances? [Solved]

Hey, I want to ensure I don’t get any memory leaks while making my game. There are some old posts on this topic but are 5 years old now. I would like to know, if I have an event listener linked to an instance, must I disconnect the event if the instance is destroyed?

For example I have a script that loads the player’s character every time the .Died:Once event fires on their Humanoid. In the event that the player leaves the game and their character gets deleted, must I now disconnect the connection for the .Died event or is it automatically removed?

1 Like

From the documentation for Instance types:

[Destroy] sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections, and calls Destroy() on all children.

So the events should disconnect automatically when the object is destroyed

6 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.