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

How do I add audio to a door?

Asked by 5 years ago
Edited 5 years ago

I've made a door that can open and close with a button you click on the side and I don't know how to add audio to it so that when it opens said audio will play and when it closes a different audio plays. I have three scripts but each script is the same just going to a different part of the door like top part goes up and bottom part goes down

Script 1. Top goes up

01db = false
02door = false
03 
04script.Parent.DoorButton.ClickDetector.MouseClick:connect(function()
05    if not db then db = true
06        if not door then door = true
07            for i=0,60 do
08                script.Parent.Doortop1.CFrame = script.Parent.Doortop1.CFrame - Vector3.new(0,-0.1,0)
09                wait()
10            end
11            script.Parent.Doortop1.CFrame = script.Parent.Doortop1.CFrame - Vector3.new(0,0.2,0)
12            db = false
13        elseif door then door = false
14            for i=0,60 do
15                script.Parent.Doortop1.CFrame = script.Parent.Doortop1.CFrame + Vector3.new(0,-0.1,0)
View all 22 lines...

Script 2. Bottom goes down

01db = false
02door = false
03 
04script.Parent.DoorButton.ClickDetector.MouseClick:connect(function()
05    if not db then db = true
06        if not door then door = true
07            for i=0,17 do
08                script.Parent.Doorbottom.CFrame = script.Parent.Doorbottom.CFrame - Vector3.new(0,0.1,0)
09                wait()
10            end
11            script.Parent.Doorbottom.CFrame = script.Parent.Doorbottom.CFrame - Vector3.new(0,0.2,0)
12            db = false
13        elseif door then door = false
14            for i=0,17 do
15                script.Parent.Doorbottom.CFrame = script.Parent.Doorbottom.CFrame + Vector3.new(0,0.1,0)
View all 22 lines...
0
You could create a sound that is a child of the scripts parent and call on it with script.Parent.SoundName:Play() ZeroNoey 19 — 5y

Answer this question