Disconnect(), does it stops thread completely?

I want to know how exactly Disconnect() works

For example:

 Event = OnSomeEvent:Connect(function()
    SomeLongCode
end)
Event:Disconnect()

Does the thread stops completely and stops further firing or it continues until stops further firing?

:Disconnect() stops the connection from the event which means that it will stop the function that the event is connected to at the line you disconnected it.
Normal functions do have this. To my knowledge, normal functions can be stopped by doing this:

local function Main()
    return Main()
end

Main()

:Disconnect() is just the replica of it but for events that directly connect to functions. You don’t have the ability to name a function when you’re just doing this: :Connect(function() end), which means that you can’t return the function without knowing it’s name.

I hope this helped, correct me if I was wrong about anything.

Good to know, thank you a lot!

1 Like

As far as I know, the function will continue to run after disconnecting the function.

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