So I been making a elevator system recently and managed to get the door opening part of the script but when I try to close the doors the doors are offset meaning that they can get stuck like in middle of a certain spot such example is here:
Opening with CFrame.new(0,-2.1,0)
https://gyazo.com/d567a8ef535e7f79d23e5401e7030c38
Closing with CFrame.new(0,2.1,0)
https://gyazo.com/f5f9500a9954e545d9bb7c1efb48040a
What Im basically trying to do is get the same tween style of doors closing to their original position rather than getting stuck halfway
Code:
function CloseLeftDoors()
local doorCloseLeft1 = {CFrame = script.Parent.Parent.Elevator.ElevatorDoor.LeftMiddlePart.CFrame * CFrame.new(0,0,2.1)}
local doorCloseLeft2 = {CFrame = script.Parent.Parent.Elevator.ElevatorDoor.LeftGlass.CFrame * CFrame.new(0,0,-2.1)}
local doorCloseLeft3 = {CFrame = script.Parent.Parent.Elevator.ElevatorDoor.LeftMiddle.CFrame * CFrame.new(0,2.1,0)}
local doorCloseLeft4 = {CFrame = script.Parent.Parent.Elevator.ElevatorDoor.LeftDoor.CFrame * CFrame.new(0,0,0.9)}
local Info = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
tweenService:Create(script.Parent.LeftMiddlePart, Info, doorCloseLeft1):Play()
tweenService:Create(script.Parent.LeftGlass, Info, doorCloseLeft2):Play()
tweenService:Create(script.Parent.LeftMiddle, Info, doorCloseLeft3):Play()
tweenService:Create(script.Parent.LeftDoor, Info, doorCloseLeft4):Play()
end
function CloseRightDoors()
local doorCloseRight1 = {CFrame = script.Parent.Parent.Elevator.ElevatorDoor.RightMiddlePart.CFrame * CFrame.new(0,0,-2.1)}
local doorCloseRight2 = {CFrame = script.Parent.Parent.Elevator.ElevatorDoor.RightGlass.CFrame * CFrame.new(0,0,-2.1)}
local doorCloseRight3 = {CFrame = script.Parent.Parent.Elevator.ElevatorDoor.RightMiddle.CFrame * CFrame.new(0,2.1,0)}
local doorCloseRight4 = {CFrame = script.Parent.Parent.Elevator.ElevatorDoor.RightDoor.CFrame * CFrame.new(0,0,-0.9)}
local Info = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
tweenService:Create(script.Parent.RightMiddlePart, Info, doorCloseRight1):Play()
tweenService:Create(script.Parent.RightGlass, Info, doorCloseRight2):Play()
tweenService:Create(script.Parent.RightMiddle, Info, doorCloseRight3):Play()
tweenService:Create(script.Parent.RightDoor, Info, doorCloseRight4):Play()
end
function OpenLeftDoors()
local doorOpenLeft1 = {CFrame = script.Parent.LeftMiddlePart.CFrame * CFrame.new(0,0,-1.8)}
local doorOpenLeft2 = {CFrame = script.Parent.LeftGlass.CFrame * CFrame.new(0,0,1.8)}
local doorOpenLeft3 = {CFrame = script.Parent.LeftMiddle.CFrame * CFrame.new(0,-1.8,0)}
local doorOpenLeft4 = {CFrame = script.Parent.LeftDoor.CFrame * CFrame.new(0,0,-0.9)}
local Info = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
tweenService:Create(script.Parent.LeftMiddlePart, Info, doorOpenLeft1):Play()
tweenService:Create(script.Parent.LeftGlass, Info, doorOpenLeft2):Play()
tweenService:Create(script.Parent.LeftMiddle, Info, doorOpenLeft3):Play()
tweenService:Create(script.Parent.LeftDoor, Info, doorOpenLeft4):Play()
end
function OpenRightDoors()
local doorOpenRight1 = {CFrame = script.Parent.RightMiddlePart.CFrame * CFrame.new(0,0,1.8)}
local doorOpenRight2 = {CFrame = script.Parent.RightGlass.CFrame * CFrame.new(0,0,1.8)}
local doorOpenRight3 = {CFrame = script.Parent.RightMiddle.CFrame * CFrame.new(0,-1.8,0)}
local doorOpenRight4 = {CFrame = script.Parent.RightDoor.CFrame * CFrame.new(0,0,0.9)}
local Info = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
tweenService:Create(script.Parent.RightMiddlePart, Info, doorOpenRight1):Play()
tweenService:Create(script.Parent.RightGlass, Info, doorOpenRight2):Play()
tweenService:Create(script.Parent.RightMiddle, Info, doorOpenRight3):Play()
tweenService:Create(script.Parent.RightDoor, Info, doorOpenRight4):Play()
end