PathfindingService isn't working for me

I’ve tried and asked other people but they don’t know either.
In the picture it shows the parts being stacked because PathfindingService results in NoPath every single time.

I just tested it after removing the wall in between and it has the exact same results.

What exactly is Hrp.Position and target.Position
not a lot of context was given to see what the problem is…

Edit: I see that they are printed… that most likely means that the positions arent the issue, so just dismiss what i said

it’s the Zombie’s PrimaryPart.Position and the Red Block’s position

In the code, it says

Instance.new("Part", workspace).Position = Hrp.Position
Instance.new("Part", workspace).Position = target.Position

then it shows a picture of where the parts are being stacked every second or so.

can you DM me a test roblox place file so i can see if i can figure it out?

edit: it doesnt have to be this exact file, just a repro file

MobsAndWeapons[2].rbxl (298.9 KB)

Here’s a chunk of Main[ModuleScript]'s code:

local current = nil
local hitspeed = Config.HitSpeed
local hitdmg = Config.HitDamage
local recalc = Config.RecalculationTime
function DoPath(target)
	if not target or not (target == current) then return nil end
	
	local path = Pathfind:FindPathAsync(Hrp.Position, target.Position)
	if not (path.Status.Value == 0) then print(path.Status) -- prints Enum.PathStatus.NoPath every time
		Instance.new("Part", workspace).Position = Hrp.Position
		Instance.new("Part", workspace).Position = target.Position
		
		wait(recalc.Value)
		return DoPath(target)
	end
	local waypoints = path:GetWaypoints()
	for i,point in pairs(waypoints) do print'd'
		if not (current == target) then return nil end
		if point.PathWaypointAction == Enum.PathWaypointAction.Walk then print'1'
			Hum:MoveTo(point.Position)
			local arrived = Hum.MoveToFinished:Wait()
			if not arrived then print'2'
				return DoPath(Hrp.Position, target.Position)
			end print'3'
		elseif point.PathWaypointAction == Enum.PathWaypointAction.Jump then
			Hum:MoveTo(point.Position)
			Hum.Jump = true
			local arrived = Hum.MoveToFinished:Wait()
			if not arrived then
				return DoPath(Hrp.Position, target.Position)
			end
		end
	end
	while current == target do print'4'
		Anims.ZombieHit:Play()
		wait(hitspeed.Value)
	end
end

I have found the problem

The red square is too big for this test, there is no possible way for the zombie to reach the middle of the cube so the pathfindingservice gives up

Making the square (6,6,6) makes this work!

It works!
Annnd… a new error appears.

Yes, i noticed that another error appeared but i havent tried finding any fix for that one

Yeah that new error was an easy fix though. It was just a misspelling.

1 Like