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

How do I make this sound play when the button is pressed?

Here is what I have so far, I want the sound to play then the door to open with at least 2 seconds wait! Here is what I have so far. It wont work! D: Also the sound is the same ID as it is in the script (Content Provider bit) The sound is in the script.

Speed = 0.1 -- Speed at which the door rises. Higher = faster. 
Time = 5 -- Time between the door totally open and starting to close.
Running = false
for x,z in pairs(script.Parent.Parent:getChildren()) do
if z.Name == "Button" then
z.CD.MouseClick:connect(function ()
if Running == true then return end
Running = true 
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=134966578")
script.Sound:Play() 
wait (2)
for i=1,script.Parent.Size.y/Speed*10+1 do 
script.Parent.CFrame = script.Parent.CFrame*CFrame.new(0,0.1*Speed,0)
wait() 
script.Sound:Stop()
end 
wait(Time)
for i=1,script.Parent.Size.y/Speed*10+1 do 
script.Parent.CFrame = script.Parent.CFrame*CFrame.new(0,-0.1*Speed,0)
wait()
end 
Running = false
end)
end
end 

2 comments

0

Are you getting any kind of output?

0

Yeah adark is right, what is the Output saying?

1 answer

✓ Accepted answer

Place the sound in the door part, not the script.

When a sound runs in a LocalScript object, it plays for the LocalPlayer, disregarding the distance from the part that the script may be in. If it runs in a server script object, it will not play. Putting the sound in the door part and having it play that there will likely fix your problem.

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