Disconnecting a connection not working?

Hello Devforum,

I have an issue where I’m trying to disconnect a connection to a humanoid event, but the connection doesn’t seem to be changed when I call :Disconnect() on it.

The script segment:

The output:
image

I’m not really experienced with memory and connections but I’m pretty sure the variable should be nil after I disconnected the connection, right?

Any help is greatly appreciated, I think this is the cause of what could be a major memory leak in my game.

Disconnecting a connection doesn’t delete it or change its value to nil; it just stops firing and changes its ‘Connected’ property to false instead of true.

3 Likes

So should I manually set the variable to nil so that it can garbagecollect?

It’s not a big deal if you don’t change its value, but I usually change its value to nil.

1 Like

Thanks for the answer, this helps a lot!

1 Like

For more information related to events you can check these articles:

1 Like