I have a GUI with a button when an object is selected I what one of two things to happen. Insert the object into a list or in the object is already in the list then to be able to edit it.
I could just swap out buttons but I thought I could use the same button. Just change text and events. I have yet to create the edit function but I have the insert function working but I kept getting multiple inserts so I added a debounce but still had the same problem.
So the problem is that although I use disconnect to turn the event off when I turn it back on it just creates a new instance that runs in parallel. I tried to destroy, remove and nil the variable for the connection but I get errors or the same problem.
So is swapping out the buttons my only solution or am I missing something?
when you connect an event, it actually returns something called an "RBXScriptConnection", and if you no longer want the event attached to the instance, make sure its saved to a variable so you can call "Disconnect".
local MyEvent = script.Parent.Something.Thingy.Part.Touched:Connect(function() print("Hello!") end -- to delete an event: MyEvent:Disconnect()