Can I do
connect = {}
connect[button] = button.MouseButton1Click:Connect(function()
connect[button]:Disconnect()
end)
This would work.
But something like this would work?
for i,v in pairs(connect) do
v:Disconnect()
end
Can I do
connect = {}
connect[button] = button.MouseButton1Click:Connect(function()
connect[button]:Disconnect()
end)
This would work.
But something like this would work?
for i,v in pairs(connect) do
v:Disconnect()
end
Yes, the Connect method returns the connected event so you can save it in the table for when you want to disconnect them. When you disconnect them, just remove the connection from the table and when you disconnect them check the .Connected
property of the signal to make sure they haven’t been already disconnected.
A loop would work?
Because when I made that, and did, print(i) it didn’t printed, (like not running)