How do i do this loop?

So i am making a game and i want to do this code right here:

local waypoints = script.Parent.Walkpoints
local MovingPart = script.Parent.MovingPart

for waypoint = 1, #waypoints:GetChildren() do
	local waypoint22 = waypoints[waypoint]

	MovingPart.MovingTo.Value = waypoint
	for i = 0,1,.01 do
		wait()
		MovingPart.CFrame = MovingPart.CFrame:Lerp(waypoint22.CFrame, i)
	end
end

loopable. i am making this for my friend and i want it to be easily customizable for him. if you know how i could do it. please let me know!

What are you trying to achieve / isn’t working with your current code?

1 Like

Definitely wondering this as well.
My first thought, though, was to turn the original ‘for’ loop into a function similar to this:

function walkPart(waypoints, part)
	for waypoint = 1, #waypoints:GetChildren() do

		--Fill this in with the rest

You may want to find a good way to create new waypoints, however