Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Your title should be specific! Describe your problem concisely?

Asked by 5 years ago

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

1 answer

Log in to vote
0
Answered by 5 years ago
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()

while true do
    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)
end

In future, do not bring scripts that are from the toolbox to this forum. This is for original work.

Ad

Answer this question