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

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

Asked by
Nidoxs 190
10 years ago

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 
0
Are you getting any kind of output? adark 5487 — 10y
0
Yeah adark is right, what is the Output saying? Hybric 271 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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.

Ad

Answer this question