I'm trying to figure out how to make a sound play when a certain part is touched. I tried before but it never played.Can someone please type in a script for me?
COMMUNITY QUESTION
How do I make a sound play when a certain part is touched?
2 answers
Assuming you have a part named Button in workspace, and a valid sound named Sound in workspace, this should work:
local debounce = false
game.Workspace.Button.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
debounce = true
game.Workspace.Sound:Play()
wait(1.5)
debounce = false
end
end)
You need: A Sound in Workspace (Call it aSound) a script in the part.
debounce = true
script.Parent.Touched:connect(function ()
if debounce == true then
debounce = false
workspace.aSound:Play()
debounce = true
end
end)
2 comments
0
Thanks! If that other guy's script doesn't work then I'll use this one.
0
K
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thanks! I'll try it and change the button and sound to what I used in the game.