Independent educational resource · Not affiliated with Roblox Corporation · Editorial standards · Contact
Vol. 2026 · Roblox Studio Development Journal
Lua
intermediatePillar Hub14 min

Pathfinding in Roblox

Navigate NPCs and objects through complex environments using PathfindingService and waypoint systems.

Maya Chen

Lead Roblox Scripting Editor

Reviewed 2026-05-1014 min readEditorial review

Introduction

PathfindingService calculates optimal routes through your game's geometry, avoiding walls and obstacles. It powers NPC movement, pet following, and automated object delivery. This hub explains path computation, waypoint traversal, and common pitfalls.

Computing a Basic Path

local path = PathfindingService:CreatePath({ AgentRadius = 2, AgentHeight = 5, AgentCanJump = true }). path:ComputeAsync(npc.HumanoidRootPart.Position, targetPosition). if path.Status == Enum.PathStatus.Success then local waypoints = path:GetWaypoints() -- move to each waypoint end

Use Cases

  • NPC patrol routes
  • Pet follow mechanics
  • Delivery missions

Best Practices

  • Recalculate when paths are blocked
  • Throttle path requests
  • Tune agent parameters to model size

Troubleshooting

Script runs but nothing happens in-game

Verify the script type matches its location. Server Scripts belong in ServerScriptService; LocalScripts in StarterPlayerScripts or StarterGui. Check the Output window in Studio for error messages.

Changes don't appear after editing

Stop and restart Play mode in Studio. Some scripts cache values on first run. For published games, republish after testing locally.

Script examples

Annotated Lua examples related to this topic.