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

How Can I Make The Sound Script That Wait For A Cool down To Click It Again Instead Of Spamming?

Asked by
ImfaoXD 158
8 years ago

I don't want a player to keep spamming and keep clicking the sound button. That would be annoying. For example; If a player clicked the sound button, then they will have to wait for it to cool down and then they can click it again. How can do that?

Brick = script.Parent
Sound = Brick.Sound

function onClicked()
Sound:Play()
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
We do not finish scripts, we only FIX them. Do the research yourself: http://wiki.roblox.com/index.php/Debounce EzraNehemiah_TF2 3552 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

You could add a debounce.

Brick = script.Parent
Sound = Brick.Sound
Debounce = false

function onClicked()
    if not Debounce then -- If the debounce is false
        Debounce = true -- Change it to true
        Sound:Play()
        wait(Sound.TimeLength) -- Wait til it ends
        Debounce = false -- Change it to false
    end -- End the if function
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
Please look here at the bottom section: https://scriptinghelpers.org/help/how-post-good-questions-answers. "Asking someone to make a script for you is not allowed", just give him the wiki site and let him do the research.  EzraNehemiah_TF2 3552 — 8y
0
@LordDragon Can you explain what part of that I failed at? I explained the code I added. InfinitivePixelsJr 542 — 8y
0
Guys, stop fighting. Please! D: It's just a website that we help each others out. Please, don't fight. D: ImfaoXD 158 — 8y
0
@LordDragonZord While asking someone to make them a full script is not allowed, making a question about something and then have someone willing to write the entire code for them is another matter. LetThereBeCode 360 — 8y
Ad

Answer this question