I installed train doors into my metro train and it's basically a left union and inside is the parts used for the position ( like OpenPos and ClosePos )
Now I wanted 1 side to open for my game so I added an if statement so like If side ( Variable ) Is "Right" Then do the tween but now it doesn't work? I added some prints and everything was fine so please help.
door script
local this = script.Parent
local TweenService = game:GetService("TweenService")
local TrainDoor = this.Carriage.TrainDoor
local Event = this.OpenDoors
local doortweenInfo = TweenInfo.new(1, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, false, 0)
function Anchor(model)
for i, v in pairs(model:GetChildren()) do
if v:IsA("UnionOperation") then
v.Anchored = true
end
end
end
function UnAnchor(model)
for i, v in pairs(model:GetChildren()) do
if v:IsA("UnionOperation") then
v.Anchored = false
end
end
end
Event.Event:Connect(function(side)
print(side)
if side == "Right" then
print("Is right")
for i,v in pairs(TrainDoor.RightSide:GetChildren()) do
if v.Name == "DoorL" then
print("Is doorL")
Anchor(TrainDoor)
TweenService:Create(v, doortweenInfo, {CFrame = CFrame.new(v.PosOpen.Position)}):Play()
delay(5, function()
TweenService:Create(v, doortweenInfo, {CFrame = CFrame.new(v.PosClosed.Position)}):Play()
wait(1)
UnAnchor(TrainDoor)
end)
end
if v.Name == "DoorR" then
print("Is doorR")
Anchor(TrainDoor)
TweenService:Create(v, doortweenInfo, {CFrame = CFrame.new(v.PosOpen.Position)}):Play()
delay(5, function()
TweenService:Create(v, doortweenInfo, {CFrame = CFrame.new(v.PosClosed.Position)}):Play()
wait(1)
UnAnchor(TrainDoor)
end)
end
end
elseif side == "Left" then
print("Is left")
for i,v in pairs(TrainDoor.LeftSide:GetChildren()) do
if v.Name == "DoorL" then
Anchor(TrainDoor)
TweenService:Create(v, doortweenInfo, {CFrame = CFrame.new(v.PosOpen.Position)}):Play()
delay(5, function()
TweenService:Create(v, doortweenInfo, {CFrame = CFrame.new(v.PosClosed.Position)}):Play()
wait(1)
UnAnchor(TrainDoor)
end)
end
if v.Name == "DoorR" then
Anchor(TrainDoor)
Anchor(TrainDoor)
TweenService:Create(v, doortweenInfo, {CFrame = CFrame.new(v.PosOpen.Position)}):Play()
delay(5, function()
TweenService:Create(v, doortweenInfo, {CFrame = CFrame.new(v.PosClosed.Position)}):Play()
wait(1)
UnAnchor(TrainDoor)
end)
end
end
end
end)

4 comments
It was working before you added it so only one side opened, right?
I want only 1 side to open because the other side would be the 2nd train
And it is printing "Is DoorL" and "Is DoorR" right?
Yes I actually fixed the problem because the Anchor Function was supposed to have TrainDoor.RightSide