Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

We do not finish scripts, we only FIX them. Do the research yourself: http://wiki.roblox.com/index.php/Debounce

1 answer

✓ Accepted answer

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)

4 comments

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. 

0

@LordDragon Can you explain what part of that I failed at? I explained the code I added.

0

Guys, stop fighting. Please! D: It's just a website that we help each others out. Please, don't fight. D:

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.