Kinda confused on this tweening

I use tweenservice for my stretcher system that I’m creating, after it goes down and up once, and attempts to go down again when it comes back up bottom legs don’t come up, they stay in the low position if that makes sense :man_shrugging:

Code:

local TweenService = game:GetService("TweenService")

local function tweenModel(model, CF)
	local CFrameValue = Instance.new("CFrameValue")
	CFrameValue.Value = model:GetPrimaryPartCFrame()

	CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
		model:SetPrimaryPartCFrame(CFrameValue.Value)
	end)

	local tween = TweenService:Create(CFrameValue, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Value = CF})
	tween:Play()

	tween.Completed:Connect(function()
		CFrameValue:Destroy()
	end)
end
local LowU1P = script.Parent.Low.Union1.Position
local LowU1O = script.Parent.Low.Union1.Orientation

local LowU2P = script.Parent.Low.Union2.Position
local LowU2O = script.Parent.Low.Union2.Orientation

local UpU1P = script.Parent.Up.Union1.Position
local UpU1O = script.Parent.Up.Union1.Orientation

local UpU2P = script.Parent.Up.Union2.Position
local UpU2O = script.Parent.Up.Union2.Orientation

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://9856348934"
animation.Parent = script

local up = true
local iswelded = false
local canmove = true
local track = nil

game.Players.PlayerAdded:Connect(function(p)
	p.Chatted:Connect(function(m)
		if m == "move" then
			if not canmove then return end
			canmove = false
			if iswelded then
				p.Character.UpperTorso.StreWeld:Destroy()
				track:Stop()
				iswelded = false
				track = nil
				
				for i,v in pairs(script.Parent:GetDescendants()) do
					if v:IsA("BasePart") then v.Anchored = true end
				end
			end

			if up then
				-- go down
				UpU1P = LowU1P
				UpU1O = LowU1O

				UpU2P = LowU2P
				UpU2O = LowU2O

				up = false
				tweenModel(script.Parent.Bed, script.Parent.BedLow.CFrame)

				local g = {Position = LowU1P, Orientation = LowU1O}
				TweenService:Create(script.Parent.Up.Union1, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), g):Play()

				local g2 = {Position = LowU2P, Orientation = LowU2O}
				TweenService:Create(script.Parent.Up.Union2, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), g2):Play()
				
				task.wait(2)
				canmove = true
			else
				-- go up
				LowU1P = UpU1P
				LowU1O = UpU1O

				LowU2P = UpU2P
				LowU2O = UpU2O

				up = true
				tweenModel(script.Parent.Bed, script.Parent.BedHigh.CFrame)

				local g = {Position = UpU1P, Orientation = UpU1O}
				TweenService:Create(script.Parent.Up.Union1, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), g):Play()

				local g2 = {Position = UpU2P, Orientation = UpU2O}
				TweenService:Create(script.Parent.Up.Union2, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), g2):Play()
				
				task.wait(2)
				UpU1P = LowU1P
				UpU1O = LowU1O

				UpU2P = LowU2P
				UpU2O = LowU2O
				canmove = true
			end
		elseif m == "weld" then
			if not canmove then return end
			
			track = p.Character.Humanoid.Animator:LoadAnimation(animation)
			track:Play()
			p.Character:MoveTo(script.Parent.PadTp.Position)

			local Weld = Instance.new("Weld")
			Weld.Name = "StreWeld"
			Weld.Part0 = p.Character.UpperTorso
			Weld.Part1 = script.Parent.WeldHandle
			Weld.C1 = CFrame.new(0, 0, 1.8)
			Weld.Parent = p.Character.UpperTorso
			iswelded = true
			
			for i,v in pairs(script.Parent:GetDescendants()) do
				if v:IsA("BasePart") then v.Anchored = false end
			end

			while iswelded and task.wait() do
				LowU1P = script.Parent.Low.Union1.Position
				LowU1O = script.Parent.Low.Union1.Orientation

				LowU2P = script.Parent.Low.Union2.Position
				LowU2O = script.Parent.Low.Union2.Orientation
				
				UpU1P = script.Parent.Up.Union1.Position
				UpU1O = script.Parent.Up.Union1.Orientation

				UpU2P = script.Parent.Up.Union2.Position
				UpU2O = script.Parent.Up.Union2.Orientation
			end
		end
	end)
end)

https://gyazo.com/9802122936bc2b0e6261fa9aa84d2241


https://gyazo.com/0c5da4ced11066a7a6d4e3619e3ee241 (gif got cut off)

patched it. I forgot to update the real up & low position, and orientation before it goes down, and after it goes up.

-- go down
				UpU1P = script.Parent.Up.Union1.Position
				UpU1O = script.Parent.Up.Union1.Orientation

				UpU2P = script.Parent.Up.Union2.Position
				UpU2O = script.Parent.Up.Union2.Orientation
				
				LowU1P = script.Parent.Low.Union1.Position
				LowU1O = script.Parent.Low.Union1.Orientation

				LowU2P = script.Parent.Low.Union2.Position
				LowU2O = script.Parent.Low.Union2.Orientation

				up = false
				tweenModel(script.Parent.Bed, script.Parent.BedLow.CFrame)

				local g = {Position = LowU1P, Orientation = LowU1O}
				TweenService:Create(script.Parent.Up.Union1, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), g):Play()

				local g2 = {Position = LowU2P, Orientation = LowU2O}
				TweenService:Create(script.Parent.Up.Union2, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), g2):Play()
				
				task.wait(2)
				canmove = true

-- go up
				LowU1P = UpU1P
				LowU1O = UpU1O

				LowU2P = UpU2P
				LowU2O = UpU2O

				up = true
				tweenModel(script.Parent.Bed, script.Parent.BedHigh.CFrame)

				local g = {Position = UpU1P, Orientation = UpU1O}
				TweenService:Create(script.Parent.Up.Union1, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), g):Play()

				local g2 = {Position = UpU2P, Orientation = UpU2O}
				TweenService:Create(script.Parent.Up.Union2, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), g2):Play()
				
				task.wait(2)
				UpU1P = LowU1P
				UpU1O = LowU1O

				UpU2P = LowU2P
				UpU2O = LowU2O
				
				LowU1P = script.Parent.Up.Union1.Position
				LowU1O = script.Parent.Up.Union1.Orientation

				LowU2P = script.Parent.Up.Union2.Position
				LowU2O = script.Parent.Up.Union2.Orientation
				canmove = true

Here’s the code hope, this helps anyone reading this thread in the future stuck on a similar issue like this.

Hey!
Sorry for bumping an old thread, but I’m trying to achieve the exact same kind of stretcher, but I’m a bad scripter, and I just broke everything. Is there any form of contact with you so we can possibly talk a bit?