Multiple npc pathfinding returning false

Im making multiple npcs pathfind at once, ive been having problems trying to fix the npcs pathfind, it works when its only used on one but breaks when used with multiple.
it returns false.

PATHFINDING MODULE

function Pathfind.MoveToPos(character, Destination)
	local Humanoid = character:FindFirstChildOfClass("Humanoid")
	local HumanoidRootPart = character.HumanoidRootPart
	
	
	
	local path = PathfindingService:CreatePath({
		["AgentCanJump"] = true,
	})
	
	local success, errorMessage = pcall(function()
		HumanoidRootPart:SetNetworkOwner(nil)
		
		path:ComputeAsync(HumanoidRootPart.Position, Destination.Position)
	end)
	
-- gets the basic stuff down.
	
	if success and path.Status == Enum.PathStatus.Success then
		
		local Waypoints = path:GetWaypoints()
		
		if Waypoints and Waypoints[3] then
			
			local Data = Waypoints[3]
			
			
			if Data.Action == Enum.PathWaypointAction.Walk or Waypoints[3].Action == Enum.PathWaypointAction.Jump then
				task.spawn(function()
					Humanoid:MoveTo(Waypoints[3].Position)
					Humanoid.Jump = true
				end)
			end
			
			Humanoid:MoveTo(Data.Position)

-- Checks actions
			
		end
	else
		return false
	end
	
end

SERVERSIDEDSCRIPT

local CollectionService = game:GetService("CollectionService")
local PathfindHandler = require(game.ReplicatedStorage.Files.Modules.Pathfind)



while task.wait(0.1) do
	task.spawn(function()
		local Base = workspace.ChosenMap:FindFirstChildWhichIsA("Folder"):FindFirstChild("MainBase")


		for i, v in pairs(CollectionService:GetTagged("Base")) do

			PathfindHandler.MoveToPos(v, Base)

-- makes all of them move at once

		end
	end)
end

2 Likes

Maybe you know it’s a good idea to read the API and make posts constructive instead of rageposting “aaa thing no work me sad”?

Without context, no one can help you.

dont be so aggressive about it? I understand if you didn’t mean to, but I listed the main problem. I think I listed everything perfectly fine? im just trying to ask for help and that’s all you can say

We need the code. Not just a description of the problem. That is what the other person meant of “without context”.

Additionally, you can add stuff like “When I do X, it can’t do Y. But if I do Z, I can do Y.” Plus some debugging logs.

1 Like

Fixed the problem, Looked at the path status and said no path, turned out my base position was too high for the enemy’s to reach and so they didn’t move proud to say everything fixed for me!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.