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

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

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

1 answer

✓ Accepted answer

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

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