Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I disable and enable a Gui button?

Asked by 4 years ago

I'm making a Gui that Tweens 2 Frames at different intervals. When the player presses the Gui activation button too fast the Frames become messed up. So I need to be able to disable the activation button for just a few moments. Any Idea on how to do that?

1 answer

Log in to vote
0
Answered by 4 years ago
local Debounce, Delay = true, 5 -- Vars

script.Parent.MouseButton1Click:Connect(function() 
    if Debounce then -- Checks if boolean is true
        print(1) -- Our code to run
        Debounce = false 
        wait(Delay) -- Delay runs
        Debounce = true
    end
end)

This is called a debounce, this is very useful for many things and especially for your case here If this helps make sure to tell me! Have a great day..

0
OMG! lol I completely forgot about that! Yep worked, thank ya! ffancyaxax12 181 — 4y
0
no problem, glad i could help. User#31525 30 — 4y
Ad

Answer this question