Do you still need to use :Disconnect() if the object pertaining to an event is nil?

Hello DevForum, I have a quick Question.

I was wondering if I would need to manually disconnect any events relating to an object that no longer exists.

An example would be the :ChildAdded() event. In this case, if a character which is linked to the event is destroyed after resetting will that result to the following event also being destroyed or will it result in a memory leak?

So, the LuaU garbage collector will automatically disconnect events unless something is using that event or it’s parameters as a dependency.

2 Likes

If the parameter the event passes through (ex: Character, for CharacterAdded) is fully destroyed, then it will garbage collect.

Thank you for the clarification

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