I am making a text button and I only want it clicked once every 2 seconds. Is there a debounce for GUI's like there are for parts?
Sort of... I wouldn't call it exactly debounce, but this sets a value to true and false so it doesn't allow them to click it again for 2 seconds. It basically does the same thing debounce would on a brick, except with some extra coding.
val = script.Parent.Able -- Name a bool value "Able" val = false script.Parent.MouseButton1Down:connect(function() if val == false then --What it's supposed to do here val = true wait(2) val = false else end end)
Debounces aren't limited to parts. It's just a matter of disabling and re-enabling a function to run. If you want to make one for a TextButton, I'd do something like this-
local btn = script.Parent local enabled = true btn.MouseButton1Click:connect(function() -- when the button is clicked if enabled then -- if it is enabled enabled = false -- disable the button -- execute your code wait(2) -- wait 2 seconds after a click enabled = true -- re-enable the button end end)