I don't know how to make this pathfinding script to loop and I need some help with it.
local torso = script.Parent.Torso.Position
local base = workspace.poopoo1.Position
local human = script.Parent.Humanoid
local path = game:GetService("PathfindingService") :FindPathAsync(torso,base)
local points = path:GetWaypoints()
if path.Status == Enum.PathStatus.Success then
for i,v in pairs(points) do
human:MoveTo(v.Position)
human.MoveToFinished:wait()
if v.Action == Enum.PathWaypointAction.Jump then
human.Jump = true
end
end
end
wait(2.5)
local torso = script.Parent.Torso.Position
local base = workspace.poopoo2.Position
local human = script.Parent.Humanoid
local path = game:GetService("PathfindingService") :FindPathAsync(torso,base)
local points = path:GetWaypoints()
if path.Status == Enum.PathStatus.Success then
for i,v in pairs(points) do
human:MoveTo(v.Position)
human.MoveToFinished:wait()
if v.Action == Enum.PathWaypointAction.Jump then
human.Jump = true
end
end
end
wait(2.5)
local torso = script.Parent.Torso.Position
local base = workspace.poopoo3.Position
local human = script.Parent.Humanoid
local path = game:GetService("PathfindingService") :FindPathAsync(torso,base)
local points = path:GetWaypoints()
if path.Status == Enum.PathStatus.Success then
for i,v in pairs(points) do
human:MoveTo(v.Position)
human.MoveToFinished:wait()
if v.Action == Enum.PathWaypointAction.Jump then
human.Jump = true
end
end
end
wait(2.5)
local torso = script.Parent.Torso.Position
local base = workspace.poopoo4.Position
local human = script.Parent.Humanoid
local path = game:GetService("PathfindingService") :FindPathAsync(torso,base)
local points = path:GetWaypoints()
if path.Status == Enum.PathStatus.Success then
for i,v in pairs(points) do
human:MoveTo(v.Position)
human.MoveToFinished:wait()
if v.Action == Enum.PathWaypointAction.Jump then
human.Jump = true
end
end
end
wait(2.5)
local torso = script.Parent.Torso.Position
local base = workspace.poopoo5.Position
local human = script.Parent.Humanoid
local path = game:GetService("PathfindingService") :FindPathAsync(torso,base)
local points = path:GetWaypoints()
if path.Status == Enum.PathStatus.Success then
for i,v in pairs(points) do
human:MoveTo(v.Position)
human.MoveToFinished:wait()
if v.Action == Enum.PathWaypointAction.Jump then
human.Jump = true
end
end
end
wait(2.5)
local torso = script.Parent.Torso.Position
local base = workspace.poopoo6.Position
local human = script.Parent.Humanoid
local path = game:GetService("PathfindingService") :FindPathAsync(torso,base)
local points = path:GetWaypoints()
if path.Status == Enum.PathStatus.Success then
for i,v in pairs(points) do
human:MoveTo(v.Position)
human.MoveToFinished:wait()
if v.Action == Enum.PathWaypointAction.Jump then
human.Jump = true
end
end
end
