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

Can you help me with sound?

Asked by 8 years ago

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?

1 answer

Log in to vote
0
Answered by
Relatch 550 Moderation Voter
8 years ago

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)   
0
Well, it is still just a spammable TixyScripter 115 — 8y
0
What he's saying is you need to add a debounce: http://wiki.roblox.com/index.php?title=Debounce Goulstem 8144 — 8y
Ad

Answer this question