Games IA ChatGPT 241 views

Roblox Enemy AI Script with Patrol, Alert, and Combat States

roblox luau npc enemy ai pathfinding state machine raycast server
SCOPE

For Roblox developers who need a reliable enemy NPC, such as a guard, monster, or soldier. The prompt asks for a single server Script with a state machine (Idle, Patrol, Alert, and Combat), detection by distance, field of view, and raycast, and movement with PathfindingService.

You provide your Explorer structure, Part names, waypoint folder, attributes, and the damage system you already use. The AI keeps those names, gathers everything configurable in a CONFIG section, and states its assumptions when information is missing, without inventing integrations. Damage, targeting, and movement stay on the server.

Use it in two steps: first the structure and assumptions, then the complete code, followed by a Studio test plan with multiple players. Adjust range, cooldown, and scan intervals to your genre and project scope.

Content
Main prompt
Act as a senior Roblox Luau developer, an expert in server-authoritative NPC AI, finite state machines (FSM), and PathfindingService. Create a single server Script, placed inside the enemy Model, with the Idle, Patrol, Alert, and Combat states, adapted to my game. Use the names I provide below literally. If information is missing, state your assumptions and gather everything in a CONFIG section at the top.
Sign in

Sign in to access this free prompt

Roblox · Luau · beta

Generated Luau script

Roblox Enemy AI Script with Patrol, Alert, and Combat States

Related Prompts