Humanoid:FollowPlayer()
Continuously follows a Player with an authored NPC character Model.
Signature
humanoid:FollowPlayer(player, modeOrBrain, brain)Parameters
| Name | Type | Description |
|---|---|---|
player | Player | Player for the NPC to continuously follow. |
modeOrBrain | Enum.FollowMode | Enum.FollowBrain | Optional mode or brain. FollowMode defaults to Companion and FollowBrain defaults to Dumb. |
brain | Enum.FollowBrain | Optional brain when a FollowMode is also supplied. Dumb keeps direct following; Smart enables obstacle-aware navigation. |
Behavior
FollowPlayer() is an authoritative server operation. It is available to public ServerScript code and is rejected from public LocalScript code.
The target is stored as a Player rather than as a one-time position. Every server simulation step Glorpia resolves that Player's current Character and Torso and updates the NPC's travel direction automatically.
The NPC uses its normal WalkSpeed, gravity, falling, body facing and R6 walking animation. The walk-cycle phase is not restarted while the target moves, so the animation remains continuous while the NPC is following.
Enum.FollowMode.Companion keeps the companion stopping distance. Enum.FollowMode.Chase removes that stopping distance and continuously drives the NPC toward the center of the Player character.
Enum.FollowBrain.Dumb is the original direct-follow controller. It heads toward the target and stops when collidable geometry blocks the route.
Enum.FollowBrain.Smart uses bounded obstacle-aware path routing. It continuously samples the short floor corridor ahead, so even small gaps are detected instead of being skipped between probes. Reachable gaps are jumped from a real takeoff point near the ledge using the Humanoid's current JumpPower, WalkSpeed, simulation step, measured gap distance and the landing platform's vertical height. Higher landings shorten the available jump range and lower landings increase the airtime. The jump arc itself is checked for blocking geometry.
If the followed Player is below the NPC, Smart searches below the actual ledge for a real CanCollide landing surface. This applies to small step-down ledges as well as larger drops, so the NPC can follow downward instead of treating every height change as a pit.
When a direct route is blocked by a wall or gap, Smart searches a larger surrounding area for a supported route, including doorways, entrances, exits and bridges around or across pits. Planned paths keep body clearance from walls and corners instead of hugging them. If the Player is substantially above the NPC, Smart also searches its nearby spatial cells for the nearest usable rung-style ladder and routes toward that ladder before climbing it. If no safe route, jump, ladder, bridge or lower platform can be found, the NPC stops in place and faces the Player instead of pacing back and forth along the obstacle edge. Companion stopping distance also checks for a clear supported route, so a nearby Player on the other side of a wall or gap is not treated as already reached.
If the Player temporarily has no Character, such as while respawning, the NPC waits in place and resumes following when the Character returns. If the Player instance is removed, following is cancelled.
FollowPlayer(player, Enum.FollowMode.Companion) remain valid and use the Dumb brain. To choose both, pass the mode and brain as the second and third arguments. Calling Move() or MoveTo() cancels the current FollowPlayer target.Example
local players = game:GetService("Players")
local npc = workspace:WaitForChild("Follower")
local humanoid = npc:WaitForChild("Humanoid")
local player = players:GetChildren()[1]
-- Existing direct companion behavior.
humanoid:FollowPlayer(player, Enum.FollowBrain.Dumb)
-- Obstacle-aware companion that can route, jump and climb.
humanoid:FollowPlayer(player, Enum.FollowBrain.Smart)
-- FollowMode and FollowBrain can also be combined.
humanoid:FollowPlayer(player, Enum.FollowMode.Chase, Enum.FollowBrain.Smart)