How to fix escelator?

Hi, i want to make a escelator and i got a script from a video. But its just made for up escelators. But i want to make it for down escelator.
here is script:

local steps = script.Parent:WaitForChild("Steps"):GetChildren()


table.sort(steps, function(a, b)

	return a.Position.Y < b.Position.Y
end)


local startPos = steps[1].Position

local endY = startPos.Y + (#steps - 1) * steps[1].Size.Y


local speed = 1


local ts = game:GetService("TweenService")
local ti = TweenInfo.new(speed, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)



while wait(speed) do

	for i, step in pairs(steps) do
		
		
		local y, z = (1 / speed) * step.Size.Y, (1 / speed) * step.Size.Z

		step.Velocity = Vector3.new(0, y, z)


		if math.floor(step.Position.Y + 0.5) >= math.floor(endY) then

			step.Position = startPos
		end


		local tween = ts:Create(step, ti, {Position = step.Position + Vector3.new(0, step.Size.Y, step.Size.Z)})

		tween:Play()
	end
end

Also i made some changes in code to make it go down, but the result is: video
here is script which i make it go down

local steps = script.Parent:WaitForChild("Steps"):GetChildren()


table.sort(steps, function(a, b)

	return a.Position.Y > b.Position.Y --changed to >
end)


local startPos = steps[1].Position

local endY = startPos.Y + (#steps - 1) * steps[1].Size.Y


local speed = 1


local ts = game:GetService("TweenService")
local ti = TweenInfo.new(speed, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)



while wait(speed) do

	for i, step in pairs(steps) do


		local y, z = (1 / speed) * step.Size.Y, (1 / speed) * step.Size.Z

		step.Velocity = Vector3.new(0, y, z)


		if math.floor(step.Position.Y + 0.5) >= math.floor(endY) then

			step.Position = startPos
		end


		local tween = ts:Create(step, ti, {Position = step.Position - Vector3.new(0, step.Size.Y, step.Size.Z)}) --changed + to -

		tween:Play()
	end
end

is there a way to make that? :confused:

the problem is starterpos? because after reaching last position it doesnt go to starterpos