What is the purpose of using :Disconnect() to disconnect something? Is it to clear the memory and prevent memory leaks?
I've personally never used it, how do you use it and what is it for (wiki doesn't explain clearly)?
What is the purpose of using :Disconnect() to disconnect something? Is it to clear the memory and prevent memory leaks?
I've personally never used it, how do you use it and what is it for (wiki doesn't explain clearly)?
:Disconnect() justs disconnects a connection. Here's an example
local connection = part.ClickDetector.MouseClick:Connect(function()
print("Clicked!")
end
wait(5)
connection:Disconnect()
What that does is it creates a connection, and when you click the ClickDetector it prints out "Clicked!". After 5 seconds, it won't print "Clicked!" again cause the connection has been disconnected.
If you still don't understand it, feel free to ask!
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
well, what does :Connect() do
I already know it connects to a function, but why would you want to disconnect a function such as the one on the 'OnUpdate' wiki page.