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

How do I make a brick that plays a sound effect every time you touch it?

Asked by 10 years ago

I've tried putting the soundID into a brick then touching it but it doesn't play sound effects. I've also tried adding a different sound inside the brick and sure enough it doesn't work. What do you think I should do ?

0
Put the code that you've tried in your post, then maybe we can see what the problem is infalliblelemon 145 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

I found this that could help you out. It kills and gives a sound but you can just remove the kill and change the sound; function onTouch(part) local humanoid = part.Parent:FindFirstChild("Humanoid") local sound = script.Parent.Bowser

if (humanoid ~= nil) then humanoid.Health = 0 sound:play(1)

end end

script.Parent.Touched:connect(onTouch)

0
Sorry the code mest up when I submitted it. MrLimitless 0 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

I haven't tried this before but this might look like this:

local part = game.Workspace.Part

function onTouched()
    part.Sound:play() -- put the sound on the part for this to work
    wait(5)
    part.Sound:Stop()
end

part.Touched:connect(onTouched)

Try reading something about the sound:

http://wiki.roblox.com/index.php?title=RBX.lua.Sound_(Object)

The wiki says that sound requires a preload for it to work. Try reading something about preload too:

http://wiki.roblox.com/index.php?title=Preload

Hope that helps!

Answer this question