these doors are supposed to open and close no matter where is the train is orientated, yet the doors still break
local TweenService = game:GetService("TweenService")
-- Constants
local TWEEN_DURATION = 1.5
local OPEN_WAIT_DURATION = 10
local SOUND_LEAD_IN = 2
-- References
local trainCar = script.Parent
local trainModel = trainCar.Parent
local leftSide = trainModel:WaitForChild("Left")
local openValue = trainModel:WaitForChild("Open")
local soundDO = trainCar:WaitForChild("DO")
local soundDC = trainCar:WaitForChild("DC")
-- State
local doorPanels = {}
local originalOffsets = {}
local cframeValues = {}
local isOperating = false
local activeTweens = {}
-- Logging
local function log(message)
print("[DoorController] " .. message)
end
-- Anchoring Utility
local function setCarAnchored(state)
for _, part in trainCar:GetDescendants() do
if part:IsA("BasePart") and not part:IsA("Seat") then
part.Anchored = state
end
end
end
-- Tween Management
local function cancelActiveTweens()
for _, tween in activeTweens do
tween:Cancel()
end
activeTweens = {}
end