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

How do I make a sound play when a certain part is touched?

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?

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)

1 comment

0

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

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.