How to rotate and tween at the same time

Here is the video
I want it to be like in a line and it slides

local Waypoints = workspace.Waypoints
local TweenService = game:GetService("TweenService")
local Way = {}

for i = 1,#Waypoints:GetChildren() do
	local v = Waypoints:FindFirstChild(tostring(i))
	table.insert(Way,{
		["Position"] = v.Position,
		["Speed"] = v:GetAttribute("Speed")
	})
end

function tween(part,pos,speed)
	local res = CFrame.lookAt(part.Position,pos).LookVector
	TweenService:Create(part,TweenInfo.new(.2,Enum.EasingStyle.Linear),{CFrame=CFrame.new(part.Position,pos + res)}):Play()
	local tween = TweenService:Create(part,TweenInfo.new((part.Position-pos).Magnitude/speed,Enum.EasingStyle.Linear),{CFrame=CFrame.new(pos,pos + res)})
	tween:Play()
	tween.Completed:Wait()
end

function start()
	for i,v in ipairs(Way) do
		tween(script.Parent,v.Position+Vector3.new(0,script.Parent.Size.Y/2),v.Speed)
	end
end

start()

Is there any fixes for this?

1 Like

corountines, this is the solution, use it to do 2 functions at the same time