Pathfinding - Returning No Path

Good day, I am having a major AI issue in OPEN AREA RPG, meaning that there are no closed doors/ intentionally no large hitboxes interfering with the path. I have seen this issue open up multiple times and others have solved it yet I cannot. I am using AI similar to zombie AI made by Y3llow Mustang on Youtube. Basically, im printing out the waypoints and it cannot form any path it’s returning NoPath. Note: There are no major/ big hitboxes, I removed them temporarily, I am using proper pathfinding arguments.

Code:

THE FUNCTION WITH THE ISSUE IS findPath(), The walkRandomly() hasn’t been used yet since there are characters near the AI - Holder.

local walkRadius = 5
	local function walkRandomly()
		local xRand, zRand = math.random(-walkRadius, walkRadius),math.random(-walkRadius, walkRadius)
		local goal = HRP.Position + Vector3.new(xRand, 0, zRand)
		
		local path = game:GetService("PathfindingService"):CreatePath(pathargs)
		path:ComputeAsync(HRP.Position, goal)
		
		local waypoints = path:GetWaypoints()
		
		
		if path.Status == Enum.PathStatus.Success then
			for _, waypoint in ipairs(waypoints) do
				if waypoint.Action == Enum.PathWaypointAction.Jump then
					Humanoid.Jump = true
				end

				Humanoid:MoveTo(waypoint.Position)
				local timeOut = Humanoid.MoveToFinished:Wait(1)
				if not timeOut then
					print("NPC: Stuck!")
					Humanoid.Jump = true
					walkRandomly()
				end			
			end
		else
			print("Path Not Successfull")
			task.wait(1)
			walkRandomly()
		end
		
	end
	

	local function checkSight(target)
		local ignore = RaycastParams.new()
		ignore.FilterType = Enum.RaycastFilterType.Blacklist
		ignore.FilterDescendantsInstances = {Character}

		local ray = workspace:Raycast(HRP.Position, (target.Position - HRP.Position).Unit * 40, ignore)
		if ray then
			local hit = ray.Instance
			if hit then
				if hit:IsDescendantOf(target.Parent) and math.abs(hit.Position.Y - HRP.Position.Y) < 3 then
					print("NPC: Target In Sight!")
					return true

				end
			end
		end
		return false
	end
	
	local function findPath(target)
		local path = game:GetService("PathfindingService"):CreatePath(pathargs)
		path:ComputeAsync(HRP.Position, target.Position)
		local waypoints = path:GetWaypoints()
		print(waypoints, path.Status)
		if path.Status == Enum.PathStatus.Success then
			for _, waypoint in ipairs(waypoints) do
				if waypoint.Action == Enum.PathWaypointAction.Jump then
					Humanoid.Jump = true
				end
				print("Moved")
				Humanoid:MoveTo(waypoint.Position)
				local timeOut = Humanoid.MoveToFinished:Wait(1)
				if not timeOut then
					print("NPC: Stuck!")
					Humanoid.Jump = true
					findPath(target)
					break
				end			
				if checkSight(target) then
					repeat
						print("Moving directly to target")
						Humanoid:MoveTo(target.Position)
						task.wait(.1)
						if target == nil then 
							break
						elseif target.Parent == nil then
							break
						end
					until checkSight(target) == false or Humanoid.Health < 1 or target.Parent.Humanoid.Health <1
					break	
				end
				if (HRP.Position - waypoint[1].Position).Magnitude > 20 then
					print("NPC: Target moved, Generating new path")
					findPath(target)
					break
				end
			end
		else
			findPath(target)
		end
	end
	
	local function findTarget()
		local distance = 50
		local target = nil
		local potentialTargets = {}
		local visibleTargets = {}
		for i,v in ipairs(workspace:GetChildren()) do
			local human = v:FindFirstChild("Humanoid")
			local Root = v:FindFirstChild("Torso") or v:FindFirstChild("HumanoidRootPart")
			if human and Root and human.Health > 1 and not v:IsDescendantOf(workspace.Dummies) and not v:FindFirstChild("SafeZone") and not v:FindFirstChild("Log") then
				table.insert(potentialTargets, Root)
			end
			if #potentialTargets > 0 then
				for i,v in ipairs(potentialTargets) do
					if checkSight(v) then
						table.insert(visibleTargets, v)
					elseif #visibleTargets == 0 and (HRP.Position - v.Position).Magnitude < distance then
						target = v
						distance = (HRP.Position - v.Position).Magnitude
					end
				end
			end
			if #visibleTargets > 0 then
				distance = 50
				for i,v in ipairs(visibleTargets) do
					if (HRP.Position - v.Position).Magnitude < distance then
						target = v
						distance = (HRP.Position - v.Position).Magnitude
					end
				end
			end
		end
		
		return target
		
	end
	
	local function main()
		local target = findTarget()
		print(target.Parent)
		if target then
			Humanoid.WalkSpeed = 12
			findPath(target)
			
		else
			Humanoid.WalkSpeed = 8
			walkRandomly()
		end
	end
	
	--- Required Checks: Health, Walkspeed >= basespeed, check loop allowance, stunned, (nearesthrp and nearesthrp.CFrame)
	-- NearestHRP = ActionService.CharacterService.FindNearestHRP(Character, 20)
	-- local OtherHumanoid = NearestHRP.Parent:WaitForChild("Humanoid")
	--and Character:GetAttribute("Stunned") ~= true	
	
	while task.wait(.1) do
		--print(Humanoid.Health ~= 0 , Character:GetAttribute("Stunned") ~= true , not Paused.Main.Loop)
		if Humanoid.Health ~= 0  and not Paused.Main.Loop then
			main()
		else
			print("Script Error!")
		end
	end

Thank you for your time on this post it’s very much appreciated! :smiley:

Turns out the problem was truly the navigational meshes/ areas being disrupted, there was a basepart -1000000 studs away from my main map disrupting the navigational areas.