.MoveToFinished is exhausting it's timer until the very last second

I am trying to get the script to stop exhausting the .MoveToFinished:Wait() timer! It keeps waiting until the very last moment to finish the movement

I’ve tried to use CHATGPT and searched up for other tutorials or posts online, but nothing has helped!

I’m a bit new to this topic in MoveTo scripting!

local Workspace = game:GetService("Workspace")
local PathfindingService = game:GetService("PathfindingService")

while true do task.wait()
	local path = PathfindingService:CreatePath({
		AgentRadius = 3,
		AgentHeight = 7,
		AgentCanJump = false
	})
	
	local finishPosition = nil
	local RandomPosition = {}
	
	for i,v in pairs(workspace.LEVELS.Level:FindFirstChildWhichIsA("Model"):GetChildren()) do
		table.insert(RandomPosition,v.EntityPosition.Position)
	end
	
	local random1 = math.random(1,#RandomPosition)
	finishPosition = RandomPosition[random1]
	
	-- Compute the path
	local success, errorMessage = pcall(function()
		local startPosition = script.Parent.Base.Position
		path:ComputeAsync(startPosition, finishPosition)
	end)

	-- Confirm the computation was successful
	if success and path.Status == Enum.PathStatus.Success then
		-- For each waypoint, create a part to visualize the path
		for _, waypoint in path:GetWaypoints() do -- This is what moves it to each waypoint
			script.Parent.Humanoid:MoveTo(waypoint.Position)
			script.Parent.Humanoid.MoveToFinished:Wait()
		end
	else
		print(`Path unable to be computed, error: {errorMessage}`)
	end
end

You dont need all that in a while true task.wait() loop, simply do the logic for looping thru the waypoints and moving the humanoid to each and waiting for the movement to finish. If you’d like I also have a pathfinding script that you can use

TY SO MUCH BRO!!! I’ve been stuck on this bug for a while and this will definitely help with my development, thank you!! (The part where you set the “:SetNetworkOwner” really helped!)