I am making a remake of a different door script I made in the past that had all doors being controlled from one script.
Here is how it works:
The script also welds all of the parts in DependentParts to MovablePart using a WeldingConstraint. There is only one issue with this: only one of the welding constraints is active at a time.
Here is my script:
function HoldingCard(plr, accessLevel)
if ((plr.Character:FindFirstChildWhichIsA("Tool") and
plr.Character:FindFirstChildWhichIsA("Tool"):FindFirstChild("AccessLevel"))
and plr.Character:FindFirstChildWhichIsA("Tool"):FindFirstChild("AccessLevel").Value >= accessLevel) then
return true
end
return false
end
function CardInBackpack(plr, accessLevel)
for _,item in pairs(plr.Backpack:GetChildren()) do
if item:FindFirstChild("AccessLevel") and item:FindFirstChild("AccessLevel").Value >= accessLevel then
return true
end
end
return false
end
for _,primaryDoor in pairs(workspace.Assets.Doors:GetChildren()) do
for __,door in pairs(primaryDoor.Doors:GetChildren()) do
for ___,dependent in pairs(door.DependentParts:GetChildren()) do
local weld = Instance.new("WeldConstraint", door.MovablePart)
weld.Part0 = door.MovablePart
weld.Part1 = dependent
end
end
for ____,trigger in pairs(primaryDoor.Triggers:GetChildren()) do
trigger.ProximityPrompt.Triggered:Connect(function(plr)
if (HoldingCard(plr, primaryDoor.DoorAccessLevel.Value) or CardInBackpack(plr, primaryDoor.DoorAccessLevel.Value)) then
trigger.ProximityPrompt.Enabled = false
local val = (primaryDoor.IsOpen.Value and -.1) or .1
primaryDoor.IsOpen.Value = not primaryDoor.IsOpen.Value
for i=1,45 do
wait(0.02)
for _____,door in pairs(primaryDoor.Doors:GetChildren()) do
door.MovablePart.CFrame = door.MovablePart.CFrame * CFrame.new(val,0,0)
end
end
trigger.ProximityPrompt.Enabled = true
end
end)
end
end
The solution I have tried was switching it to a normal weld but that didn’t work either.
I was wondering, how do I fix this?