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

How do I put a cooldown on a ClickDetector?

Asked by 3 years ago

I can't find anything related on this online so I'm just asking here.

2 answers

Log in to vote
2
Answered by 3 years ago
Edited 3 years ago

I made a quick script showing you how it works!

local debounce = false -- debounce is a var you can make to do cooldowns ect.
local click = script.Parent.ClickDetector

click.MouseClick:Connect(function(player) -- fires once the click detector has been activated
    if debounce == false then -- check if debounce isn't on the cooldown.
        debounce = true -- if debounce isn't on cooldown, it will fire and set debounce to true making it so you can't click it again.
        wait(3) -- waits 3 seconds, you can change this to what time you want
        debounce = false -- after the wait() finished, it will set debounce to false allowing you to activate the click detector again.
    end
end)
0
why do you even need to put player after function WINDOWS10XPRO 438 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
local cooldown = false
local click = [[your click detector place here]]

click.MouseClick:Connect(function()
    if not cooldown then
        cooldown = true
        [[your scripts here]]
        wait(2) -- change 2 to how many seconds you want
        cooldown = false
    end
end)

Answer this question