Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Make a Roblox NPC Follow Players and Pathfind Safely

Run NPC target selection and pathfinding on the server, move its Humanoid through waypoints, and recompute routes when obstacles or target movement make them stale.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To make an NPC behave consistently for everyone in a Roblox multiplayer server, run its target selection and pathfinding in a server-side Script. Use PathfindingService to compute a route, move the NPC’s Humanoid through its waypoints, and recompute when the route is blocked or out of date. Keep attacks, damage, rewards, and other shared decisions on the server too.

What makes an NPC “AI” in this setup?

Here, AI means scripted behavior: the NPC selects a player, calculates a route, and responds to changes such as an obstacle or a target moving away. This approach uses Roblox Studio’s built-in services; it does not require a separate AI product.

As an Amazon Associate I earn from qualifying purchases.

A moving character model needs a Humanoid and a usable root part, commonly named HumanoidRootPart. The server script chooses a target and issues movement commands. Roblox’s pathfinding guide describes computing paths and moving Humanoids through waypoints.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why should shared NPC behavior run on the server?

Roblox uses a client-server model: the server is authoritative for shared game state, while clients display the replicated world and handle local presentation. If each player’s client independently controls an NPC, players can see different decisions or movement. A server-controlled NPC gives the experience one decision-maker.

Server pathfinding also avoids a streaming issue: a client may not have distant or streamed-out objects in its local world and therefore may not be able to calculate a route involving them. For an NPC that should navigate consistently for everyone, compute its route on the server.

Roblox Creator Hub’s security guidance puts the principle plainly: “The server must be the ultimate source of truth for all simulation states, rules, player progression, and critical decisions.” See Security and cheat mitigation tactics.

Set up the NPC and server script

  1. Insert or build a rig with a Humanoid and HumanoidRootPart, then place it in Workspace. Make sure the parts are configured so the Humanoid can move; anchoring the rig in a way that prevents movement will stop it.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Put the controlling code in a server Script. Use ServerScriptService for shared game logic, or put a server Script in the NPC model if its behavior belongs with that model. If you use an unusual location, check Studio’s current Script type and RunContext guidance.

  3. On the server, choose an eligible target. Check that the player’s character exists, that it is alive if your game requires that, and that it has a usable root position. Set explicit rules for target range and when the NPC should switch targets.

  4. Create a path using PathfindingService:CreatePath(). Set agent parameters to approximate the NPC’s dimensions and movement abilities, then compute a route from the NPC’s root position to the target’s position.

  5. Check that the path status indicates success before reading its waypoints. Move the Humanoid along the route, honoring waypoint actions such as jumps when needed.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Roblox’s pathfinding documentation covers path computation, waypoint movement, and blocked-path handling. A path can fail if the destination is unreachable, the agent dimensions do not suit the rig, or the start or destination is not on navigable geometry. Treat failure as a normal condition; do not assume a waypoint list exists.

Keep paths current without recalculating constantly

A calculated route can become unusable if something blocks it or the target moves far enough to make the route stale. Listen for Path.Blocked and recompute when the blocked waypoint is still ahead on the NPC’s route. A blockage behind the NPC does not necessarily require a new path.

Use bounded waits and handle computation or movement failures so the NPC does not stall indefinitely. Recalculate when the target’s movement makes the current route meaningfully outdated, but do not recompute every frame. There is no single official update interval that suits every map, NPC count, and server workload; tune the cadence to the experience and observe server performance.

Server pathfinding or client pathfinding?

Choice What it means Best fit
Server-computed path The server selects the target and computes the route using its view of the world; NPC decisions are shared. Shared NPCs whose behavior should be consistent for every player, especially in experiences using streaming.
Client-computed path A client computes a route using the world objects available to that client; streamed-out objects may be missing. Local, cosmetic behavior that does not determine shared game outcomes.

For a multiplayer NPC that pursues players or affects gameplay, server computation is the practical default. Roblox’s pathfinding guide discusses the streaming limitation, and its security guidance explains why consequential decisions should not be trusted to clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep interactions and consequences authoritative

If a client needs to request an interaction, a RemoteEvent can carry that request. It does not make the request valid: clients can submit fabricated arguments or fire events at excessive rates. Before changing NPC or game state, validate the player’s state, distance, permitted action, cooldown, and argument shape on the server. Do not accept a client-supplied target or reward as authoritative without checking it.

Keep target selection, hit decisions, damage, loot, progression, and other shared outcomes on the server. Clients can render the replicated NPC and handle cosmetic presentation. Roblox explains event direction and the client-server boundary in Remote events and callbacks.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Should you force server physics ownership?

Server-side AI and server-owned physics are related, but they are separate choices. The server can make the NPC’s decisions while Roblox automatically assigns an unanchored physics assembly to a nearby client for simulation. For eligible assemblies, a server script can call SetNetworkOwner(nil) to force server ownership. Roblox warns that forcing ownership can make motion feel jittery, so use it only when the control or security need outweighs that trade-off. Anchored parts remain server-owned, and ownership calls cannot change that.

Ownership choice Trade-off Use when
Automatic ownership Roblox can distribute physics simulation to nearby clients. The NPC’s physics does not require stricter server control and its movement behaves acceptably.
Forced server ownership Gives the server physics control for an eligible unanchored assembly, but can make visible motion jittery. The NPC’s physical state needs tighter control and the resulting motion remains acceptable.

See Roblox Creator Hub’s network ownership guide for automatic ownership, server ownership, and the trade-offs.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Test the behavior in a multiplayer session

Use Studio’s server-and-client testing rather than relying only on a solo run. Add obstacles and test blocked routes, a target that moves, and a target that dies or respawns. If the experience uses streaming, test with streaming enabled. Studio’s network simulation tools can add latency.

  • NPC does not move: Check that the model has a live Humanoid and root part, that its parts are not anchored in a movement-blocking configuration, and that the controlling script is running on the server.
  • Path status is not successful: Check whether the destination is reachable, the agent parameters fit the rig, and the start and destination are on navigable geometry. Handle the failure before accessing waypoints.
  • NPC gets stuck after starting: Check whether the route is blocked ahead and whether the script recomputes when that blockage affects the remaining path.
  • It works alone but not on a server: Check script execution context, replication, network ownership, and assumptions about what the server or client can see. Reproduce the problem in a multi-client Studio session.
  • One client finds a path and another does not: Streaming may leave one client without relevant world objects. Calculate shared NPC routes on the server.
  • Players can exploit an interaction: Validate the action, distance, player state, arguments, and rate on the server before applying consequences.

When the broader server authority model is relevant

Putting NPC logic in a server script does not require enabling Roblox’s broader server authority model. That model is a wider networking architecture with setup requirements and concepts such as prediction and rollback. Consider it separately if the game’s architecture calls for it, and check Roblox’s current server authority model documentation for its status and requirements.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.