I tried this but Always when touched it play itself more of the same sounds:
script.Parent.Touched:connect(function(hit)
workspace.Sound:play()
end)
I tried this but Always when touched it play itself more of the same sounds:
script.Parent.Touched:connect(function(hit)
workspace.Sound:play()
end)
Hello. You have to use Debounce. Here's an example:
local CanPlay = true
script.Parent.Touched:Connect(function(hit)
if CanPlay then
CanPlay = false
YourSound:Play()
wait(5)
CanPlay = true
end
end)
Debounce is like a delay. The Script will not continue until the debounce condition is met.
make a Debounce stored on a variable, something like this:
local played = false
script.Parent.Touched:Connect(function(hit)
if played == false then
workspace.Sound:Play()
played = true
wait(2) -- change this for the cooldown of it
played = false
end
end)
Pretty basic. Hope I helped.
This discussion is preserved as it was. New answers, comments, and votes are closed.