Skip to main content
skill CX Codex

roblox-npc-ai — Claude Code skill for Roblox NPC AI

Writes and fixes Roblox NPCs: pathfinding, state machines, player detection, spawns and AI update loops.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add TabooHarmony/roblox-brain --skill roblox-npc-ai -a claude-code
Open on GitHub

What roblox-npc-ai does

The skill loads when you build or debug enemies, bots or friendly NPCs in Roblox. It ships Luau patterns: PathfindingService:CreatePath with AgentRadius, AgentHeight, AgentCanJump and a Costs table where math.huge marks a region as impassable. A state machine section covers idle → patrol → chase → attack → flee → dead, and detection runs cheapest check first — distance, then field of view, then a raycast.

There is a separate note on physics network ownership. Classic projects can call SetNetworkOwner(nil), but that is not full security. On Server Authority projects you configure the authority model instead of treating network ownership as the security boundary. Worth checking how your server-side control is set up before bots start moving.

For the update loop the guidance is to throttle and stagger AI based on NPC count, path cost and profiler evidence rather than one fixed tick rate. Decisions and movement stay on the server; the client handles presentation. Spawners, lifecycle cleanup and performance budgets live in references/full.md. In Studio, test Workspace.PathfindingUseImprovedSearch on your own maps first, since the flag is not scriptable.

What it helps with

  • build an NPC route to a target with PathfindingService
  • set up an enemy state machine with chase and attack
  • detect players by distance, FOV cone and raycast
  • stagger AI updates so the server stops lagging
  • fix an NPC that gets stuck or walks through walls

Example prompts for the agent

  • Build a patrolling Roblox NPC that paths with PathfindingService and switches to chase when it sees the player
  • My NPC gets stuck at a door — add PassThrough and a PathfindingLink to the path setup
  • Stagger the AI update loop so the server holds up with a lot of enemies

How to install roblox-npc-ai

1Skills CLI (Vercel)

npx skills add TabooHarmony/roblox-brain --skill roblox-npc-ai -a claude-code

2Manually: put the files in place

~/.claude/skills/roblox-npc-ai/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/roblox-npc-ai/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about roblox-npc-ai

How do I install roblox-npc-ai in Claude?

Run npx skills add TabooHarmony/roblox-brain --skill roblox-npc-ai -a claude-code. The skill file then sits at ~/.claude/skills/roblox-npc-ai/SKILL.md.

What does roblox-npc-ai do?

It gives the agent ready patterns for Roblox NPCs: pathfinding, state machines, player detection, spawns and AI update loops.

Does it cover server lag from NPCs?

Yes. The update loop section says to throttle and stagger AI decisions based on NPC count, path cost and profiler evidence instead of one universal tick rate.

Source text

SKILL.md · MIT
---
name: roblox-npc-ai
description: "Use when creating or fixing Roblox NPCs, bots or enemies: pathfinding, state machines, line of sight, spawns, AI update loops."
when_to_use: "Also when NPCs get stuck, walk through walls, chase wrongly, lag the server, or bots need to fill empty servers."
last_reviewed: 2026-10-14
sources:
  - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/characters/pathfinding.md
  - https://create.roblox.com/docs/projects/server-authority
  - original
---

# Roblox NPC & AI

## When to Load

Load for NPCs/enemies: pathfinding, state machines, LOS/FOV detection, spawns, AI loops, or physics ownership.

## Quick Reference

### PathfindingService

```luau
local path = PathfindingService:CreatePath({
    AgentRadius = 2, AgentHeight = 5, AgentCanJump = true,
    Costs = { Water = 20, DangerZone = math.huge },
})
path:ComputeAsync(npcPos, targetPos)
if path.Status ~= Enum.PathStatus.Success then return end
for _, wp in path:GetWaypoints() do
    if wp.Action == Enum.PathWaypointAction.Jump then humanoid.Jump = true end
    humanoid:MoveTo(wp.Position)
    if not humanoid.MoveToFinished:Wait() then return end
end
```

- Recompute on blocked with a bounded retry or cancellation policy.
- In Studio, test `Workspace.PathfindingUseImprovedSearch` on representative maps before rollout; it is not scriptable.
- Avoid long requests and repeated recomputation. Moving collidable geometry can trigger navigation-mesh work.
- Region modifiers: anchored part + `PathfindingModifier` Label → Costs
- `PassThrough = true` for doors; `PathfindingLink` for disconnected navmesh
- `math.huge` cost = non-traversable

### State Machine

`idle → patrol → chase → attack → flee → dead`
- idle/patrol → chase (player detected) → attack (in range) → idle (lost)
- any → flee (health low) → idle (safe); any → dead (health ≤ 0)
- Transitions own movement changes, target cleanup, and cancellation

### Detection (distance → FOV → LOS)

1. **Distance** `(a-b).Magnitude`: cheapest, always first
2. **FOV** `forward:Dot(toTarget)` cosine; use a configured cone for your game, not a universal angle
3. **LOS** `workspace:Raycast`: expensive, last
- If the design includes hearing or proximity detection, make it a separate configured signal rather than a universal FOV bypass.

### Network Ownership
- Classic projects may use `SetNetworkOwner(nil)` for physics-sensitive NPCs, but it is not complete security. In Server Authority projects, configure the authority model instead of treating network ownership as the security boundary.

### Update Loop

- Throttle and stagger AI based on NPC count, path cost, and profiler evidence, not a universal tick rate. Keep NPC decisions and movement server-side; client code may handle presentation.

For spawners, lifecycle cleanup, timeout handling, and performance budgets, load `references/full.md`.

© TabooHarmony · MIT · TabooHarmony/roblox-brain

Similar skills

Everything for Game dev and 3D: Unity, Unreal, Godot, Blender →

From the same set28

roblox-monetization A skill for Roblox purchase work: Game Passes, Developer Products, subscriptions, private servers and policy checks. Useful when a purchase stops granting. CX Codex +1 1,900installs roblox-luau-core A skill for writing and debugging Luau that teaches the agent the language's semantics and catches syntax carried over from JavaScript or Python. CX Codex +1 1,900installs roblox-networking Audits Roblox client-server networking: RemoteEvent validation, rate limits, NaN checks, and exploit defense. Useful when writing network remotes. CX Codex +1 1,900installs roblox-luau-types A skill for Luau type annotations: generics, unions, narrowing, strict mode, module type exports. Useful when migrating to --!strict. CX Codex +1 2,000installs roblox-security Audits and hardens Roblox game code against exploits, remote abuse, and DataStore duplication. Useful before releasing places or updating in-game economies. CX Codex +1 1,900installs roblox-camera A skill for scripting Roblox camera behavior: CFrame placement, screen raycasts, first and third person, cutscenes. Useful when the camera jitters or clips through walls. CX Codex +1 1,800installs roblox-tooling Helps configure and fix Roblox development toolchains: Rojo, Wally, pesde, Selene, StyLua, Lune, and CI/CD pipelines. CX Codex +1 1,800installs roblox-analytics A skill for Roblox analytics work: AnalyticsService events, economy, funnels, onboarding traces and rate limits. Useful when instrumenting a feature or finding where players drop off. CX Codex +1 1,800installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor