Garry's Mod Wiki

NPC:MoveOrder

  NPC:MoveOrder( Vector position )

Description

Makes the NPC walk toward the given position. The NPC will return to the player after amount of time set by player_squad_autosummon_time ConVar.

Only works on Citizens (npc_citizen) and is a part of the Half-Life 2 squad system.

The NPC must be in the player's squad for this to work.

Arguments

1 Vector position
The target position for the NPC to walk to.

Example

A console command that makes all Citizens on the map (if they are in the player's squad) try to go to where the player is looking at.

concommand.Add( "movenpcs", function( ply ) for id, npc in ipairs( ents.FindByClass( "npc_citizen" ) ) do npc:MoveOrder( ply:GetEyeTrace().HitPos ) end end )