Hello, this is my first forum post so please excuse me if I make a mistake.
I have a garage script that used to work, but now doesn’t. When I say used to work, I mean yesterday it worked and now it does not. I have not edited the code at all.
So the door won’t actually open or close. The proximity prompt that I’m using changes, and the sound plays, but nothing actually happens.
I’ve looked through the code and nothing pops out as a red flag.
local P = script.Parent
local da1 = P.DA1
local db1 = P.DB1
local da2 = P.DA2
local db2 = P.DB2
local da3 = P.DA3
local db3 = P.DB3
local group = 7963624 --Group ID
function CreateDoorMotor(a,b,s)
local m = Instance.new("Motor", script)
m.Part0 = a
m.Part1 = b
m.MaxVelocity = s
return m
end
function WeldPair(x, y)
local weld = Instance.new("Weld",x)
weld.Part0 = x
weld.Part1 = y
weld.C1 = y.CFrame:toObjectSpace(x.CFrame);
end
function WeldAll(model, main) -- model can be anything
if model:IsA("BasePart") then WeldPair(main, model) end
for _,v in pairs(model:GetChildren()) do WeldAll(v, main) end
end
function UnanchorAll(model) -- model can be anything
if (model:IsA("BasePart")) then model.Anchored = false end
for _,v in pairs(model:GetChildren()) do UnanchorAll(v) end
end
local ma1 = CreateDoorMotor(P.DAH, da1.A, 0.03)
local mb1 = CreateDoorMotor(P.DBH, db1.A, 0.03)
local ma2 = CreateDoorMotor(da1.B, da2.A, 0.06)
local mb2 = CreateDoorMotor(db1.B, db2.A, 0.06)
local ma3 = CreateDoorMotor(da2.B, da3.A, 0.06)
local mb3 = CreateDoorMotor(db2.B, db3.A, 0.06)
WeldAll(da1, da1.A)
WeldAll(db1, db1.A)
WeldAll(da2, da2.A)
WeldAll(db2, db2.A)
WeldAll(da3, da3.A)
WeldAll(db3, db3.A)
UnanchorAll(da1)
UnanchorAll(db1)
UnanchorAll(da2)
UnanchorAll(db2)
UnanchorAll(da3)
UnanchorAll(db3)
function ToggleDoor()
local open = ma1.DesiredAngle == 0
ma1.DesiredAngle = (open) and math.rad(85) or 0
mb1.DesiredAngle = (open) and -math.rad(85) or 0
ma2.DesiredAngle = (open) and -math.rad(170) or 0
mb2.DesiredAngle = (open) and math.rad(170) or 0
ma3.DesiredAngle = (open) and math.rad(170) or 0
mb3.DesiredAngle = (open) and -math.rad(170) or 0
if (open) then
P.B.A:Play()
P.B.CD.ActionText = "Close"
else
P.B.B:Play()
P.B.CD.ActionText = "Open"
end
end
P.B.CD.Triggered:connect(function(player)
if player:IsInGroup(group) then
ToggleDoor()
end
end)
Please let me know if there is a solution to this.