local Pathfiding = game:GetService("PathfindingService")
local Body = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")
num = 1
while true do
local Pointpart = game.Workspace.PointPart:FindFirstChild("Point"..num)
Body:MoveTo(Pointpart.Position)
Body.MoveToFinished:wait(1)
if Body.MoveToFinished then
num = num +1
end
end
I’m pretty sure its because they think they already reached the point. Also try to re-read Pathfinding because it gives a lot of useful information on how to properly use this service
When you do Body.MoveToFinished:Wait(), there’s no need to add an if condition below because it will wait until it’s finished. I don’t think you’re supposed to put a number parameter there as well. Also, the wait in Body.MoveToFinished:Wait() should have a capital W I think.
I have done something similar to this, you might just try to read and change my code
local PathfindingService = game:GetService("PathfindingService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
while wait(math.random(5, 15)) do
local NPC = game:GetService("ReplicatedStorage").NPC:Clone()
NPC.Parent = workspace
for _, v in pairs(NPC:GetChildren()) do
if v:IsA("BasePart") then
v:SetNetworkOwner(nil)
end
end
local Humanoid, Char = NPC.Humanoid, NPC
local path1 = PathfindingService:CreatePath()
path1:ComputeAsync(Char.HumanoidRootPart.Position, workspace.AI_IN.Position)
coroutine.wrap(function()
local waypoints = path1:GetWaypoints()
for index, waypoint in pairs(waypoints) do
Humanoid:MoveTo(waypoint.Position)
Humanoid.MoveToFinished:Wait()
end
local path2 = PathfindingService:CreatePath()
path2:ComputeAsync(Char.HumanoidRootPart.Position, workspace.AI_OUT.Position)
local waypoints = path2:GetWaypoints()
for _, waypoint in pairs(waypoints) do
Humanoid:MoveTo(waypoint.Position)
Humanoid.MoveToFinished:Wait()
end
wait(1)
Char:Destroy()
end)()
end