I’m making a lift as a project to improve my scripting skills. The lift actually works pretty well, apart from the inner doors. They are attached to the lift and as such should follow the lift, and move at the same position as the lift. I tried using coroutines to constantly update the variable of the lift position but this hasn’t helped the situation.
The relevant code:
local LiftPos = Lift.Position
local newThread = coroutine.create(function()
while wait() do
LiftPos = Lift.Position
end
end)
coroutine.resume(newThread)
local InDoorGoals1 = {Position = Vector3.new(LiftPos.X-InDoor1.Size.X-2.711, LiftPos.Y+5.8, LiftPos.Z-5.5)}
local InDoorGoals2 = {Position = Vector3.new(LiftPos.X+InDoor1.Size.X+2.711, LiftPos.Y+5.8, LiftPos.Z-5.5)}
local InDoorCloseGoals1 = {Position = Vector3.new(LiftPos.X-2.71, LiftPos.Y+5.8, LiftPos.Z-5.5)}
local InDoorCloseGoals2 = {Position = Vector3.new(LiftPos.X+2.71, LiftPos.Y+5.8, LiftPos.Z-5.5)}
local TweenCloseIndoor1 = TweenService:Create(InDoor1, DoorOpenTweenfo, InDoorCloseGoals1)
local TweenCloseIndoor2 = TweenService:Create(InDoor2, DoorOpenTweenfo, InDoorCloseGoals2)
local TweenIndoor1 = TweenService:Create(InDoor1, DoorOpenTweenfo, InDoorGoals1)
local TweenIndoor2 = TweenService:Create(InDoor2, DoorOpenTweenfo, InDoorGoals2)
local function OpenInDoors(InDoor)
TweenIndoor1:Play()
TweenIndoor2:Play()
end
local function CloseInDoors(InDoor)
TweenCloseIndoor1:Play()
TweenCloseIndoor2:Play()
end
There is a lot more code than this, so if you want context here is the entire script:
Video of the issue: