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

How to make a sound play when somewone touches a part?

Asked by 10 years ago

I know its OnTouch and I know what to do but I need help on the code can you help?

1 answer

Log in to vote
0
Answered by 10 years ago

So put a sound in Workspace, name it Sound

This first one is if you just want it to play, without a debounce

function onTouch(part) 
    game.Workspace.Sound:Play()
end
script.Parent.Touched:connect(onTouch)

If you want a debounce use this

function onTouch(part) 
if debounce==false then
debounce=true
end
game.Workspace.Sound:Play()
wait(time)--Put here how long the actual song is
debounce=false  

end
script.Parent.Touched:connect(onTouch)

This is off the top of my head, if it is wrong, I am sorry

Ad

Answer this question