Tween going the wrong place!

Hello developers!

I am working on an elevator door.
While scripting the open tween, I noticed an issue. Every time the tween plays, it goes to it’s last known position. Example: If I go to floor 2 and it was at floor 1 the door opens and at the same time goes to floor 1

Script
--- TweenService and TweenTimes ---
local TweenService = game:GetService("TweenService")
local TweenTime1 = TweenInfo.new(2)
local TweenTime2 = TweenInfo.new(12)

--- Objects ---
local Door1 = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Door1",5)
local Door2 = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Door2",5)
local Rope1 = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Top",5).RopeConstraint1
local Rope2 = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Top",5).RopeConstraint2

--- ClickDetector And Values ---
local Click = script.Parent:WaitForChild("ClickDetector" ,5)
local Moving = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Moving",5).Value
local FloorValue = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("FloorValue",5).Value

if Door1 ~= nil and Door2 ~= nil and Click ~= nil then
	Click.MouseClick:Connect(function(Player)
		--- Close Tweens ---
		local Door1CloseGoal = {}
		Door1CloseGoal.Position = Vector3.new(Door1.Position.X, Door1.Position.Y, Door1.Position.Z - 1.5)
		local Door1Close = TweenService:Create(Door1, TweenTime1, Door1CloseGoal)
		--------------------------------------------------------------------------------------------------
		local Door2CloseGoal = {}
		Door2CloseGoal.Position = Vector3.new(Door2.Position.X, Door2.Position.Y, Door2.Position.Z + 1.5)
		local Door2Close = TweenService:Create(Door2, TweenTime1, Door2CloseGoal)

		--- Open Tweens ---
		local Door1OpenGoal = {}
		Door1OpenGoal.Position = Vector3.new(Door1.Position.X, Door1.Position.Y, Door1.Position.Z + 1.5)
		local Door1Open = TweenService:Create(Door1, TweenTime1, Door1OpenGoal)
		--------------------------------------------------------------------------------------------------
		local Door2OpenGoal = {}
		Door2OpenGoal.Position = Vector3.new(Door2.Position.X, Door2.Position.Y, Door2.Position.Z - 1.5)
		local Door2Open = TweenService:Create(Door2, TweenTime1, Door2OpenGoal)
		--------------------------------------------------------------------------------------------------

		--- Rope Tweens ---
		--- Up Tweens
		local Rope1UpGoal = {}
		Rope1UpGoal.Length = 1.1
		local Rope1Up = TweenService:Create(Rope1, TweenTime2, Rope1UpGoal)
		--------------------------------------------------------------------------------------------------
		local Rope2UpGoal = {}
		Rope2UpGoal.Length = 1.1
		local Rope2Up = TweenService:Create(Rope2, TweenTime2, Rope2UpGoal)
		--- Down Tweens ---
		local Rope1DownGoal = {}
		Rope1DownGoal.Length = 23.005
		local Rope1Down = TweenService:Create(Rope1, TweenTime2, Rope1DownGoal)
		--------------------------------------------------------------------------------------------------
		local Rope2DownGoal = {}
		Rope2DownGoal.Length = 23.005
		local Rope2Down = TweenService:Create(Rope2, TweenTime2, Rope2DownGoal)

		if Moving ~= true and FloorValue ~= 1 then
			Moving = true
			FloorValue = 0
			workspace.Close:Play()
			Door1Close:Play()
			Door2Close:Play()
			Door1Close.Completed:Connect(function()
				wait(0.5)
				Rope1Down:Play()
				Rope2Down:Play()
				Rope1Down.Completed:Connect(function()
					wait(1)
					Moving = false
					FloorValue = 1
					workspace.Open:Play()
					Door1Open:Play()
					Door2Open:Play()
				end)
			end)
		end
	end)
end

Thanks! Waiting for a reply.

Hi!

Do you update the “CFrameToStartTweenAt” after you’ve moved the elevator?

Edit:

Also statements like

if Door1 ~= nil then

is like saying

if NotNil ~= nil then

Instead just do

if NotNil then

or in your case

if Door1 then

Also instead of this:

Door1CloseGoal.Position = Vector3.new(Door1.Position.X, Door1.Position.Y, Door1.Position.Z - 1.5)

Take the Position, and apply the Z offset after, it’s way shorter.

Door1CloseGoal.Position += Vector3.new(0,0,-1.5) -- Haven't tested if "+=" works with Vector3, if not do the one below
Door1CloseGoal.Position = Door1CloseGoal.Position + Vector3.new(0,0,-1.5)

Neither of the options work.

Don’t know what you mean by that. Can you explain what it exactly does?

Please let me know the output, it should work the same as yours.

When you start a tween, and you want to change it’s position, you start out with defining what position it should start from, and go to. For example

TweenGoal = {Position = DoorPosition + Vector3.new(0,10,)}

That first “DoorPosition” is the “CFrameToStartTweenAt” or in this case “PositionToStartTweenAt”