roblox-npcs
Skill25 starsChanged 56 days agoMITView on GitHub
Build or debug Roblox NPC navigation and behavior. Use for PathfindingService, modifiers and links, blocked paths, patrol or chase logic, streaming, and scaling NPC counts.
In this repository16 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- roblox-animationSkill
- roblox-audioSkill
- roblox-coreSkill
- roblox-datastoresSkill
- roblox-gamepassesSkill
- roblox-mcpSkill
- roblox-networkingSkill
- roblox-open-cloudSkill
- roblox-physicsSkill
- roblox-rojoSkill
- robloxSkill
- roblox-teleportSkill
- roblox-testingSkill
- roblox-user-interfacesSkill
- roblox-vfxSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Use PathfindingService for navigation on Roblox's navigation mesh.
- Very specific: line 138
Use WaypointSpacing = math.huge to reduce intermediate waypoints for long straight runs.
- Distinctive: line 139
Consider simplifying agent geometry or using fewer active agents.
- Very specific: line 159
Always set an explicit Humanoid:MoveTo timeout and cancel it when the waypoint is reached or the follower is stopped.
- Very specific: line 161
Stop path followers and clean up Heartbeat connections when the Humanoid dies or the NPC is destroyed.
- Very specific: line 163
Use PathfindingLink labels to trigger custom traversal logic (boats, teleporters, ladders).
- Distinctive: line 173
Run on the server for authoritative AI.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
roblox-npcs
Official sources:
- https://create.roblox.com/docs/en-us/characters/pathfinding
- https://create.roblox.com/docs/en-us/workspace/streaming
- Engine classes:
PathfindingService,Path,PathWaypoint,PathfindingModifier,PathfindingLink,Humanoid
Use PathfindingService for navigation on Roblox's navigation mesh. Build patrol, chase, and other behavior around its computed paths.
PathfindingService basics
Create a path:
local PathfindingService = game:GetService("PathfindingService")
local path = PathfindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = true,
AgentCanClimb = false,
WaypointSpacing = 4,
Costs = {
Water = 20,
DangerZone = math.huge,
}
})
path.CalculationSecondsTimeout = 1Compute and follow:
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local success, err = pcall(function()
path:ComputeAsync(rootPart.Position, endPos)
end)
if success and path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
-- follow waypoints with Humanoid:Move()
endAgent parameters
| Parameter | Default | Purpose |
AgentRadius | 2 studs | Minimum clearance from obstacles |
AgentHeight | 5 studs | Vertical clearance |
AgentCanJump | true | Allows jump waypoints |
AgentCanClimb | false | Allows climbing truss parts |
WaypointSpacing | 4 studs | Distance between intermediate waypoints |
Costs | nil | Material/region/link traversal cost |
Path.CalculationSecondsTimeout limits how long the solver may run per ComputeAsync call. Set it after CreatePath and before computing.
PathWaypoint actions
Each waypoint has a Position and an Action:
Enum.PathWaypointAction.Walk: normal movement.Enum.PathWaypointAction.Jump: trigger jump.- Custom labels like
"Climb"or"UseBoat"from PathfindingModifiers/Links.
Pathfinding modifiers
PathfindingModifier instances on anchored, non-colliding parts let you influence path cost:
Label: key used inCoststable.PassThrough: iftrue, the volume is ignored by the navmesh and treated as traversable empty space (e.g., zombies "hearing" through doors).
Example:
local path = PathfindingService:CreatePath({
Costs = {
Water = 20,
DangerZone = math.huge,
UseBoat = 2,
}
})Pathfinding links
PathfindingLink connects two Attachments with a custom label and cost, allowing paths across normally untraversable gaps.
Use for:
- Boats across water
- Teleporters
- Ladders
- One-way jumps
Your movement code checks the waypoint label and runs the custom traversal logic.
Movement patterns
Follow
Continuously recompute a path to a moving target. Throttle recomputation (e.g., every 0.5–1 s) and only recompute if the target moved far enough.
Patrol
Cycle through a list of fixed points. Recompute when blocked.
Chase
Like follow, but validate line-of-sight and distance server-side. Don't trust client-reported positions for authoritative AI.
State machine
Common NPC states: Idle, Patrol, Chase, Attack, Return. Each state handles its own path computation and Humanoid control.
Streaming compatibility
- Server-side scripts have full world state and can compute paths to any part.
- Client-side scripts may fail if the destination has streamed out. Use
workspace.PersistentLoadedand persistent models for client path destinations. - Recompute paths when dynamic/streamed obstacles block the way.
Limitations
- Direct line-of-sight distance ≤ 3,000 studs.
- Computation node budget ≈ 20,000 nodes.
- Waypoint Y coordinate must be between -65,536 and +65,536 studs.
- Incompatible parameters (e.g.,
AgentCanJump = falseto a jump-only destination) will fail.
Performance at scale
- Recompute paths on a staggered schedule, not every frame.
- Share target positions across similar NPCs when possible.
- Use
WaypointSpacing = math.hugeto reduce intermediate waypoints for long straight runs. - Consider simplifying agent geometry or using fewer active agents.
- For very large worlds, split into regions or use local patrol paths.
Common mistakes
- Computing paths every frame.
- Ignoring blocked-path events and letting NPCs walk into walls.
- Trusting client position for authoritative AI.
- Forgetting
pcallaroundComputeAsync. - Using material names incorrectly in
Costs(must matchEnum.Materialnames as strings).
Scripts
scripts/NPCPathFollower.lua: Humanoid-based path follower with blocked-path recompute, custom-label support, and connection cleanup.scripts/PatrolBehavior.lua: state-driven patrol/chase behavior with spatial detection and throttled recomputation.scripts/PathfindingUtility.lua: helpers for throttled recomputation and waypoint formatting.
Best practices
- Set
Path.CalculationSecondsTimeoutafterCreatePathto cap solver time. - Always set an explicit
Humanoid:MoveTotimeout and cancel it when the waypoint is reached or the follower is stopped. - Detect targets with spatial queries such as
workspace:GetPartBoundsInRadiusinstead of scanning every player each frame. - Stop path followers and clean up
Heartbeatconnections when theHumanoiddies or the NPC is destroyed. - For respawning NPCs, create a new behavior instance for the new character model and
Destroythe old one. - Use
PathfindingLinklabels to trigger custom traversal logic (boats, teleporters, ladders). The follower invokes a registered handler; if none exists, the waypoint falls back to normal movement. - To enable climbing, set
AgentCanClimb = trueand provideTrussPartsurfaces. Climb waypoints have theLabel"Climb". PathfindingModifierparts must beAnchored = trueandCanCollide = false.
How to proceed
- Define the agent's size and movement abilities.
- Build the world with modifiers/links for special regions.
- Implement a path-follower that handles waypoints, jumps, and blocked events.
- Layer a state machine for complex behaviors.
- Run on the server for authoritative AI; use client only for visual prediction.
- Profile with MicroProfiler and stagger recomputation for many agents.
<!-- catalog:references:start -->Reference index
- modifiers-links-and-streaming.md: Route NPCs through special regions or handle streamed geometry.
- npc-behavior-patterns.md: Implement patrol, chase, combat, or state transitions.
- pathfinding-service-details.md: Configure agents, compute paths, or handle blocked waypoints.
- performance-and-scaling.md: Reduce pathfinding and simulation cost as NPC counts grow.
<!-- catalog:references:end -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

