PathFindingService not going to certain positions

I’m trying to make realistic npc’s that wander around and after sometime decide to go home.
But PathFindingService isn’t going to the house positions for some reason.
Does anyone have a fix?

Code:

local housetable = workspace.Houses:GetChildren()
local NPCHome = housetable[math.random(1,#housetable)]
NPCHome.Color = Color3.fromRGB(255, 0, 0)
local pathfindingService = game:GetService("PathfindingService")
local char = script.Parent.Parent
local hum = char:FindFirstChildOfClass("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")
script.Parent.Values.Home.Value = NPCHome

local walkinghome = false

function pathToLocation(location)
	local path = pathfindingService:CreatePath{AgentCanClimb = true, AgentCanJump = true}
	path:ComputeAsync(root.Position, location)
	local waypoints = path:GetWaypoints()
	for k, waypoint in pairs(waypoints) do
		hum:MoveTo(waypoint.Position)
		if waypoint.Action == Enum.PathWaypointAction.Jump then
			hum:ChangeState(Enum.HumanoidStateType.Jumping)
		end
		hum.MoveToFinished:Wait()
	end
end

while wait(1) do
	local rand = math.random(1,5)
	if rand == 1 then
		if walkinghome == false then
			print("going home")
			walkinghome = true
			char.Wander.Enabled = false
			pathToLocation(NPCHome.Position)
		end
	end
end

It gets the random house position perfectly, and it also decides to go home perfectly.
The only thing wrong is that it wont walk home.

What do you mean the NPC doesn’t go to that position?
Does the NPC walk somewhere else or the NPC can’t walk?
A video would be more helpful.

It must have to do with the character itself, make sure no parts are anchored and use prints to make sure that everything in the script is working fine.

It walks nowhere, it just starts standing there. forever

It walks to 0,0,0 perfectly with the same system.

It may be that when trying to find a path it simply cannot find it, a print would help:

if path.Status == Enum.PathStatus.NoPath then
	warn("NO PATH")
end

Below ComputeAsync.

It prints it, so it doesn’t have a path.

Yes, it means that the NPC couldn’t find a path.
Roblox added a quick “Navigation Mesh” option, if you can’t find it, it’s in Studio settings, activate it and see how clear the area is.
image

This is the navigation mesh:


I know the map is ugly, it’s not done.

I’m not sure, but it could be due to the thickness of the part, idk, you could add an Attachment that indicates the entry and use that to find the path.

I’ll try that then.

30charcharchar

That somehow worked? I have no idea how that works!