Roblox NPC stuck at a wall with pathfinding debug visualization showing the NavMesh

Roblox NPC Pathfinding Not Working? Common Fixes

Your NPC should walk from point A to point B. Instead, it slams into a wall, gets stuck on a staircase, walks in circles, or just stands still. Roblox PathfindingService is powerful but unforgiving when misconfigured. Most pathfinding failures come from a small set of common issues: wrong agent parameters, unhandled path statuses, missing blocked event handlers, and NavMesh geometry problems. This guide covers each failure mode and the exact fix.

Agent Parameters: The First Thing to Check

When you create a path with PathfindingService:CreatePath(), you pass an AgentParameters table. If these do not match your NPC's actual size, the path will either fail to compute or route through spaces the NPC cannot physically fit. AgentRadius is the most critical parameter: it defines a cylinder around the agent that must not intersect geometry. Set it to half your NPC's HumanoidRootPart width plus a small buffer (0.5-1 stud). AgentHeight must match or exceed the NPC's actual height including the head. AgentCanJump must be true if your NPC needs to traverse vertical gaps, and AgentCanClimb must be true for TrussParts. If the path returns NoPath status, your agent parameters are likely too large for the environment. Test by temporarily reducing AgentRadius to 1 and checking if the path computes. If it does, the issue is tight spaces in your map, not a pathfinding bug.

  • AgentRadius: half the NPC width + 0.5-1 stud buffer
  • AgentHeight: NPC full height including head
  • AgentCanJump: true if the NPC needs to jump gaps or curbs
  • AgentCanClimb: true if TrussParts exist in the path

Path Status: Stop Ignoring the Return Value

After calling Path:ComputeAsync(start, goal), always check Path.Status before using the path. The possible values are Success (path found), NoPath (no valid route exists), and ClosestNoPath (partial path to the nearest reachable point). Most developers only handle Success and ignore the other two, which leaves the NPC standing still with no error or feedback. For NoPath, log the start and end positions and visualize them in Studio to understand why no route exists. Common causes: the goal is inside a wall, the goal is on a different floor with no navigable connection, or the agent is too large for the available space. For ClosestNoPath, you can either move the NPC to the closest reachable point as a fallback or reject the path entirely and try a different goal. Never skip the status check because a failed path returns zero waypoints and your movement logic will silently do nothing.

Handling Blocked Paths and Recomputation

Once a path is computed, it represents the state of the world at that moment. If a door closes, another NPC moves into the way, or the player moves, the path may become blocked. Connect to Path.Blocked to detect when a waypoint becomes unreachable after computation. In the handler, recompute the path from the NPC's current position to the goal. Without this handler, the NPC will walk to the blocked waypoint and stand there forever. Recompute the path on a timer as well (every 1-2 seconds during active pursuit) to account for moving targets. Be careful not to recompute too frequently because ComputeAsync is not free. Debounce recomputation by checking if the target has moved more than a threshold distance (5-10 studs) since the last computation before recomputing. For NPCs chasing a player, recompute only when the player has moved significantly or when a blocked event fires.

NavMesh Problems: When the Map Is the Bug

Roblox generates the navigation mesh (NavMesh) automatically from your map geometry. You can visualize it in Studio via Settings > Studio > Show Navigation Mesh. If the NavMesh has gaps where you expect walkable surfaces, the geometry is confusing the generation. Common culprits: thin Parts (under 1 stud thick) used as floors may not register as walkable, MeshParts with complex collision geometry create unpredictable NavMesh regions, overlapping Parts create seams in the NavMesh, and decorative parts on the ground (small rocks, debris) create tiny obstacles that fragment the mesh. Fix these by ensuring floors are at least 1 stud thick, using simple box collisions for MeshParts via CollisionFidelity set to Box, and setting small decorative objects to CanCollide false so they do not affect the NavMesh. For stairs, standard Roblox staircase geometry (0.5-1 stud step height) generates a NavMesh ramp automatically. Custom staircase meshes often do not.

Jump Links and Vertical Navigation

If your NPC needs to jump between platforms or climb ledges, you must handle jump waypoints explicitly. When iterating through path waypoints, check each Waypoint.Action. If it equals Jump, set Humanoid.Jump to true before moving to that waypoint. Without this check, the NPC will walk to the jump point and stand still because Humanoid:MoveTo() does not automatically jump. For vertical navigation across floors connected by ladders, set AgentCanClimb to true and use TrussParts as the climbable surface. If your environment uses non-Truss ladders (MeshParts that look like ladders but are not TrussParts), the pathfinding system cannot recognize them. Either swap the visual mesh for a TrussPart with the mesh applied as a visual overlay, or create a PathfindingLink that manually connects the NavMesh regions above and below the ladder. PathfindingLinks are invisible Parts with a PathfindingModifier that tells the system a connection exists between two otherwise disconnected areas.

Frequently Asked Questions

Why does my NPC walk into walls instead of around them?

Your AgentRadius is likely too small, causing the path to route too close to walls. Increase AgentRadius to half the NPC width plus 1 stud. Also verify the wall has CanCollide enabled because non-collidable walls do not affect the NavMesh.

How often should I recompute the NPC path?

For chasing a player, recompute every 1-2 seconds or when the target moves more than 5-10 studs from the last path goal. Also recompute immediately when Path.Blocked fires. Avoid recomputing every frame because ComputeAsync has a performance cost.

My NPC gets stuck on stairs. How do I fix it?

Ensure stairs use step heights of 0.5-1 stud. Set AgentCanJump to true. If using MeshPart stairs, set CollisionFidelity to Box so the NavMesh generates a clean ramp. Visualize the NavMesh in Studio to confirm it covers the staircase surface.

Can NPCs open doors using pathfinding?

Not automatically. Use a PathfindingLink on the door with a custom label. When the NPC reaches a waypoint with that label, trigger a door-opening function in your script, wait for the door animation, then continue the path. The pathfinding system handles routing through the link; your code handles the door interaction.

Looking for assets? Browse the library →