I need to have both doors open, but swing open different ways (right now, all doors swing open to the left)
The door on the right should swing open to the right
Example of a building with only 1 door
How I lay out the ‘Door’. The model contains all the vital stuff, so the 2 Door parts are each individual Door, Light is behind the doors, and used to teleport the player, and TeleportPoint is where they get teleported too
-- Open/close the CurrentDoor
local function NearestDoorChanged(door)
if not CurrentDoor then
CurrentDoor = door
end
if door then
-- Open
DoorOpen:Play()
for _, v in pairs(door:GetChildren()) do
if v.Name == 'Door' then
local Goal = {CFrame = v.Hinge.CFrame:ToWorldSpace(CFrame.Angles(0, -math.rad(100), 0))}
local Tween = TweenService:Create(v.Hinge, TweenInfo.new(0.5, Enum.EasingStyle.Bounce), Goal)
Tween:Play()
if v.Parent ~= CurrentDoor then
-- Close the original door (resets the door position if player enters)
for _, v in pairs(CurrentDoor:GetChildren()) do
if v.Name == 'Door' then
local Goal = {CFrame = v.Hinge.CFrame:ToWorldSpace(CFrame.Angles(0, math.rad(100), 0))}
local Tween = TweenService:Create(CurrentDoor.Hinge, TweenInfo.new(0.5), Goal)
Tween:Play()
end
end
end
end
end
else
if DoorIsLocked then
DoorIsLocked = false
return
end
-- Close
for _, v in pairs(CurrentDoor:GetChildren()) do
if v.Name == 'Door' then
local Goal = {CFrame = v.Hinge.CFrame:ToWorldSpace(CFrame.Angles(0, math.rad(100), 0))}
local Tween = TweenService:Create(v.Hinge, TweenInfo.new(0.5), Goal)
Tween:Play()
end
end
end
CurrentDoor = door
end
-- Find the door that is nearest to the player
local function GetNearestDoor()
local Character = Player.Character
if not Character then return end
local HumanoidRootPart = Character:FindFirstChild('HumanoidRootPart')
if not HumanoidRootPart then return end
local MinDistance, Door = 8, nil
for _, v in pairs(AllDoors) do
local Distance = (v.Position - HumanoidRootPart.Position).Magnitude
if Distance < MinDistance then
MinDistance, Door = Distance, v.Parent.Door
end
end
return Door
end
Only pasted chunks of the code, as it’s probably too long to read and fully understand, so just kept the vital stuff for now