Claude Skill

roblox-npc-ai

Use when creating Roblox NPCs or enemies with pathfinding, state machines, line-of-sight or FOV detection, spawns, or AI update loops.

LLM Mart · 0 points · 1 views 0 listing impressions 0 install-command copies
Download TabooHarmony-roblox-brain-skills_gameplay_roblox-npc-ai-ceee4aa.zip · 9 KB

Install

skills CLI npx skills add https://github.com/TabooHarmony/roblox-brain/tree/main/skills/gameplay/roblox-npc-ai
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install tabooharmony-roblox-brain@llmmart
Git git clone https://github.com/TabooHarmony/roblox-brain.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole tabooharmony/roblox-brain collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

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

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.

Files (roblox-brain)
  • references
    • full.md 20.5 KB
      Loading…
  • SKILL.md 2.8 KB
    ---
    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`.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.