How would I make a part seamlessly loop?

I’m trying to accomplish something like this where essentially there’s always a part where the white is while moving.

It looks like this currently.

local tS = game:GetService("TweenService")
local partCycle = script.Parent
local movingParts = partCycle.MovingParts

-- Settings

local refreshTime = 10

-- Script

local positions = {
	movingParts:FindFirstChild("1").PrimaryPart.Position,
	movingParts:FindFirstChild("2").PrimaryPart.Position,
	movingParts:FindFirstChild("3").PrimaryPart.Position
}

local currentOrder = 1

while true do
	
	wait(refreshTime)
	
	if currentOrder == 1 then
		tS:Create(movingParts:FindFirstChild("1").PrimaryPart, TweenInfo.new(refreshTime), {CFrame = CFrame.new(positions[2])}):Play()
		tS:Create(movingParts:FindFirstChild("2").PrimaryPart, TweenInfo.new(refreshTime), {CFrame = CFrame.new(positions[3])}):Play()
		wait(refreshTime/4)
		movingParts:FindFirstChild("3"):SetPrimaryPartCFrame(CFrame.new(positions[1]))
		currentOrder = 2
	elseif currentOrder == 2 then
		tS:Create(movingParts:FindFirstChild("3").PrimaryPart, TweenInfo.new(refreshTime), {CFrame = CFrame.new(positions[2])}):Play()
		tS:Create(movingParts:FindFirstChild("1").PrimaryPart, TweenInfo.new(refreshTime), {CFrame = CFrame.new(positions[3])}):Play()
		wait(refreshTime/4)
		movingParts:FindFirstChild("2"):SetPrimaryPartCFrame(CFrame.new(positions[1]))
		currentOrder = 3
	elseif currentOrder == 3 then
		tS:Create(movingParts:FindFirstChild("2").PrimaryPart, TweenInfo.new(refreshTime), {CFrame = CFrame.new(positions[2])}):Play()
		tS:Create(movingParts:FindFirstChild("3").PrimaryPart, TweenInfo.new(refreshTime), {CFrame = CFrame.new(positions[3])}):Play()
		wait(refreshTime/4)
		movingParts:FindFirstChild("1"):SetPrimaryPartCFrame(CFrame.new(positions[1]))
		currentOrder = 1
	end
	
end
1 Like

I’d recommend using tween.Completed:Connect() to reset the position once the tween is done