I want my door to play sounds when opening, and closing.
I have a script inside of my Door (to open it), and I do not know how to implement this myself.
I do not know how to script, and I unfortunately I am too busy/occupied to learn Scripting, so I don’t know how to do this myself.
I have a ProximityPrompt in the Model, and a loose script in the model, for the door (The Door works fine)
local Hinge = script.Parent.PrimaryPart
local opened = false
local Promt = script.Parent:WaitForChild("ProximityPrompt")
function OpenDoor()
if opened == false then
opened = true
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0))
wait()
end
else
opened = false
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-5), 0))
wait()
end
end
end
Promt.Triggered:Connect(function(Players)
OpenDoor()
end)
script.Parent.Door1.ProxomityPrompt.Triggered:Connect(OpenDoor)
Lastly,
Thanks for anyone that could figure this out, or help me with this
I appreciate it!
local Hinge = script.Parent.PrimaryPart
local opened = false
local Promt = script.Parent:WaitForChild(“ProximityPrompt”)
function OpenDoor()
local sound = put the sound instance here
local closingsound = put the closing sound here
if opened == false then
opened = true
sound:Play()
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrameCFrame.Angles(0, math.rad(5), 0))
wait()
end
else
opened = false
closingsound:Play()
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrameCFrame.Angles(0, math.rad(-5), 0))
wait()
end
end
end
Promt.Triggered:Connect(function(Players)
OpenDoor()
end)
script.Parent.Door1.ProxomityPrompt.Triggered:Connect(OpenDoor)
I looked at the script again, and noticed it’s throwing out some red lines, I’m not sure if it’s errors, or just some reminders of some sorts? I don’t know, anyways, here they are:
That’s because the variable is empty, put the sound instances into the variables, for instance put “script.WhateverYourSoundName” onto the opening sound variable and put “script.WhateverYourClosingSoundName” onto the closing sound variable