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
04 | script.Parent.DoorButton.ClickDetector.MouseClick:connect( function () |
05 | if not db then db = true |
06 | if not door then door = true |
08 | script.Parent.Doortop 1. CFrame = script.Parent.Doortop 1. CFrame - Vector 3. new( 0 ,- 0.1 , 0 ) |
11 | script.Parent.Doortop 1. CFrame = script.Parent.Doortop 1. CFrame - Vector 3. new( 0 , 0.2 , 0 ) |
13 | elseif door then door = false |
15 | script.Parent.Doortop 1. CFrame = script.Parent.Doortop 1. CFrame + Vector 3. new( 0 ,- 0.1 , 0 ) |
18 | script.Parent.Doortop 1. CFrame = script.Parent.Doortop 1. CFrame + Vector 3. new( 0 , 0.2 , 0 ) |
Script 2. Bottom goes down
04 | script.Parent.DoorButton.ClickDetector.MouseClick:connect( function () |
05 | if not db then db = true |
06 | if not door then door = true |
08 | script.Parent.Doorbottom.CFrame = script.Parent.Doorbottom.CFrame - Vector 3. new( 0 , 0.1 , 0 ) |
11 | script.Parent.Doorbottom.CFrame = script.Parent.Doorbottom.CFrame - Vector 3. new( 0 , 0.2 , 0 ) |
13 | elseif door then door = false |
15 | script.Parent.Doorbottom.CFrame = script.Parent.Doorbottom.CFrame + Vector 3. new( 0 , 0.1 , 0 ) |
18 | script.Parent.Doorbottom.CFrame = script.Parent.Doorbottom.CFrame + Vector 3. new( 0 , 0.2 , 0 ) |