Using PathFindingService twice

I’ll go straight to the point, i have been learning PathFindingService for some time. This is the script and result of it i’ve done for demonstration:

local service = game:GetService("PathfindingService")

wait(5)

local humanoid = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")

local path = service:CreatePath()
path:ComputeAsync(torso.Position, game.Workspace.endp.Position)
local waypoints = path:GetWaypoints()

for i, waypoint in pairs(waypoints) do
	local part = Instance.new("Part")
	part.Shape = "Ball"
	part.Material = "Neon"
	part.Size = Vector3.new(0.5,0.5,0.5)
	part.Position = waypoint.Position + Vector3.new(0,2,0)
	part.Anchored = true
	part.CanCollide = false
	part.Parent = game.Workspace
	
	if waypoint.Action == Enum.PathWaypointAction.Jump then
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
	humanoid:MoveTo(waypoint.Position)
	humanoid.MoveToFinished:Wait()
end

humanoid:MoveTo(game.Workspace.endp.Position)

https://gyazo.com/2c3419c1ce7ec8761a27f17338d1e8a6

Basically what i want to know is how can i make it so when it is done doing the PathFinding, after touching the green part it starts a new pathfinding for another part.

Any help is appreciated, thanks.

1 Like

Isn’t there a “Touched” event for parts?

I mean yes but i don’t think that would be very how do i say it, professional, just cloning scripts inside of a player constantly. It just doesn’t seem like a viable way to rely on