So I currently have this Sound script.
script.Parent.Sound2:Play()
wait(2)
I have it set to an onTouch but people can spam it massively... Can you let me know how I could fix it?
So I currently have this Sound script.
script.Parent.Sound2:Play()
wait(2)
I have it set to an onTouch but people can spam it massively... Can you let me know how I could fix it?
Try this, tell me the problem if there is one.
debounce = false --use a debounce to check if it's playing already or not
script.Parent.Touched:connect(function(hit) --touched event
if debounce == false then --after it's touched, if debounce is false then
debounce = true --changes debounce to true
script.Parent.Sound2:Play() --plays sound/song
wait(60) --waits 60 seconds (the length of a song)
debounce = false --resets debounce to false, so it's playable after 60 seconds
script.Parent.Sound2:Stop() --stops the song
else --otherwise song is already playing
print('already playing') --prints that it's already playing
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Well, it is still just a spammable
What he's saying is you need to add a debounce: http://wiki.roblox.com/index.php?title=Debounce