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

How do you make it so you cant spam a click detector?

Asked by 6 years ago

my shower keeps turning off and off after spamming it with 10 clicks

1 answer

Log in to vote
1
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

You would add a debounce so that there was a cooldown between clicks:

local debounce = true
local cooldown = 5 --change to seconds between clicks
script.Parent.ClickDetector.MouseClick:Connect(function()
    if debounce then
        debounce = false
        --do shower script
        wait(cooldown)
        debounce = true
    end
end)
0
Thanks for spreading to the world how amazing debounces are. DatOneRandomDude 69 — 6y
Ad

Answer this question