Can someone help me code a cool down on this?

Can someone help me put a 1 minute cool down on this?

1 Like

I see you’re doing a car spawn this might help. This tutorial shows how to make a car spawn button that if something is in the way it won’t spawn another something like the one in Prison Life. This one should work better because with debounce/wait it still will spawn. Hope this helped from John. :smiley:

2 Likes

https://developer.roblox.com/en-us/articles/Debounce

Hope this helps! :stuck_out_tongue_winking_eye:

3 Likes

debounce

local cooldown = 60
local pressed = false
script.Parent.MouseButton1Click:Connect(function()
    if (not pressed) then
        pressed = true
        local clone = game.ServerStorage.Cycle:Clone()
        clone.Parent = workspace
        clone:MakeJoints()
        wait(cooldown)
        pressed = false
    end
end)
2 Likes

Okay thank’s I will try that. Doing now will edit when done!

2 Likes

@ScytheSlayin I tried that already.

1 Like

Quick thing: Wait(1) isn’t 1 minute, that’s 1 second.

2 Likes

Okay thank’s I will try that. Doing now will edit when done! I know @anxyeity! EDIT - It debounce did not work did I do it right?

Are you sure this isn’t due to a misplaced end? Also, did you define what “Mouse” is?

No. I did not define what mouse is how would I go about doing that?

In line 13.

Just do this:


script.Parent.MouseButton1Click

Like this?

1 Like

Yes. Script should work now.

(30 chars)

1 Like

I am actively testing it!
I will put text here to get 30 characters

1 Like

Remove the wait(60) in line 6.

But I want it to cool down 1 min
(30 CHARS)

You have a cooldown in the debounce.

You have the “cooldown = 60” in there. You don’t need 2. It’s breaking your script completely.

@ppwwppw2 As mentioned above use a debounce. The easiest way to script a debounce is really something like this:

local debounce = false


if debounce == true then
    return
end
    debounce = true
    --whatever you want scripted
    wait(60) -- time for debounce 
    debounce = false
end

You haven’t actually pasted your script so I can’t show you where to put it but essentially put it inside the MouseButtonClick function and put what you want to happen after said line that I have commented on as whatever you want scripted.

1 Like