If i have a mouseclick event that was set on a certain button gui, but i want to write another mouseclick event to that same gui later on how can i erase the first connected event from triggering and only trigger the new one?
✓ ANSWER ACCEPTED
Can you clear MouseButton1Click events from a button gui?
1 answer
✓ Accepted answer
Yes, you can Disconnect connections to an RBXScriptConnection object that was created through a Connect().
local connection = button.MouseButton1Click:Connect(function()
print("Before disconnecting.")
end)
wait(5) -- waits 5 seconds just for demonstration purposes
connection:Disconnect()
connection = button.MouseButton1Click:Connect(function()
print("After disconnecting.")
end)
When you initially click, it will print "Before disconnecting." However, after 5 seconds, it will Disconnect() the MouseButtonClick connection, and the new Connect()'s function definition will make it print "After disconnecting."
2 comments
0
I like it.
0
Thanks brother big help
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You simply can't