Garage Script not Working [SOLVED]

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.

image

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.

1 Like

Probably has to do with your group… are you still part of that group? has the id changed?

1 Like

The group ID is the same and I’m the owner of the group. Even when I remove the group only access part of the script, it still doesn’t work. I’ve attached a video above of what it looks like.

All I can think of since the script is running past the opening function and playing sounds and changing text, is that the doors are anchored somehow?

Edit: is there anything you added to door that isnt a Basepart?

1 Like

There are a bunch of Welds inside every single part in the model, is it possible that’s the problem?
Edit: Nvm, but no, I added nothing to the door. All I did was change the proximity prompt

Show the properties of the prompt please

Edit: but the prompt is working

Thank you so much. I actually found a part I added by mistake beforehand. It works now!

1 Like