15 min

NPCs (non-player characters) can add a lot of depth to a game. All of the following NPCs can be visually customized, their behavior modified, and the zombie/soldiers can even defend an area by attacking players or other characters.

To use an NPC in your game:

  1. Select one of the following:
Drooling Zombie
RO-01 Robots
NP-C 9000 Robots
  1. On the NPC’s item page, click the green Get button and confirm the transaction.
  2. In Roblox Studio, open the toolbox (ViewToolbox).
  3. Select your toolbox Inventory section.
  1. Locate the NPC and click it to add it into the place.

Character Structure

Each NPC is structured as follows, but note that its model may not contain all objects listed.

[NPC] (Model)
Animations (Folder) — Contains extra animations used by the zombie and soldier characters.
AttackAnimation (Animation) — Plays during attempts to deal damage to another character.
DeathAnimation (Animation) — Plays when the character dies.
InitialPoses (Folder) — Contains posing information.
Animate (Script) — Loads and plays animations on the rig.
ScaleDampeningPercent (NumberValue) — Defines how animation speeds are modified as the character is scaled (less than 1 implies animation playback scales inversely as a character is scaled).
PlayEmote (BindableFunction) — This can be invoked by other scripts in order to force the assumption of a pose.
[Pose] (StringValue) — Reference to a playable animation category such as idle, jump, walk, etc.
[Animation] (Animation) — Defines one of possibly several animations loaded on the rig when the pose is made.
Weight (NumberValue) — Used in selecting one of multiple animations to play while the pose is assumed; typically used to add variety to idle and dance poses.
[Accessory] (Accessory) — One of possibly multiple accessories for the NPC such as hats, weapons, etc.
Health (Script) — Typically regenerates the Humanoid health over time. Disabling this will prevent the character from regenerating health.
Humanoid (Humanoid) — Manages Humanoid/Health|Health, Humanoid/WalkSpeed|WalkSpeed, Humanoid/DisplayDistanceType|DisplayDistanceType, etc.
Animator (Animator) — Manages playback of Animation|Animations on the character using AnimationTrack|AnimationTracks.
NPC (Script) — Defines character-specific behaviors such as roaming, attacking, etc.
Maid (ModuleScript) — Defines a class useful in releasing resources used.
Ragdoll (ModuleScript) — Defines a function that transforms a character into a loose, physics-affected body.
RigTypes (ModuleScript) — Defines helper functions used in different sets of rig joints.
RbxNpcSounds (Script) — Defines and manages behavior related to character sound effects like running, dying, etc.
[BodyParts] (BasePart|BaseParts) — Various character body parts attached to the HumanoidRootPart or neighboring body parts through Motor6D or constraint objects.
AvatarPartScaleType (StringValue) — Determines how the part will be scaled; values can be Classic, ProportionsNormal, or ProportionsSlender.
OriginalSize (Vector3Value) — Determines the size of the part when the character scaling is 1.
[Attachment] (Attachment) — Defines a point relative to the individual part which scripts, effects, and objects such as a Tool or Accessory may utilize during positioning.
[Motor6D] (Motor6D) — An animated joint between two body parts. Note that Animator|Animators depend on the name of Motor6D|Motor6Ds to be consistent with that of the Motor6D|Motor6Ds used when an animation was created, so avoid renaming this object.
[Joint] (WeldConstraint; Constraint; JointInstance) — A non-animated joint between two body parts.
[Sound] (Sound) — Commonly found in the head or HumanoidRootPart; plays sounds from within the rig as controlled by the RbxNpcSounds script.
HumanoidRootPart (BasePart) — A special invisible part that's considered the root of the rig; this is also the Model/PrimaryPart|PrimaryPart of the character's Model.
[Configuration] (Configuration) — Contains value objects which tune various behaviors as outlined in the next section.
Design Notes
  • The visual appearance of an NPC can be customized by adding/modifying various [BodyParts] objects and by adding Accessory objects.
  • The Soldiers, Drooling Zombie, and NP-C 9000 Robots use Rthro as the base of their rig. However, the RO-01 Robots use a modified Rthro base that adds thruster parts connected to the UpperTorso using WeldConstraint|WeldConstraints. Using simple joints in this way lets you include extra geometry for your characters without changing the original base rig.
  • At a basic level, NPC animations can be customized by modifying the Animation/AnimationId|AnimationId of existing Animation objects within the Animate script poses, or those within the Animations folder. Such a change is essentially an asset swap; to change the finer details, you'll need to create custom copies of existing animations, and to play animations under different conditions, you'll need to edit the Animate or NPC scripts directly. For more information, see articles/using animations in games|Using Animations in Games.

Modifying Basic Behavior

Each NPC includes a Configuration object within its hierarchy which acts as a container of value objects. These are used by the NPC script to tune various behaviors. Unless otherwise specified, these apply to all of the characters.

[Configuration] (Configuration)
DestroyOnDeath (BoolValue) — Causes the entire NPC to be destroyed shortly after it dies. Disable this for ragdolls to be persistent.
PatrolEnabled (BoolValue) — Causes the NPC to wander in an area around its starting position.
PatrolRadius (NumberValue) — Defines the maximum distance an NPC will wander from its starting position, assuming PatrolEnabled is true.
RagdollEnabled (BoolValue) — Causes the NPC to go limp when it dies, instead of breaking apart.
AttackDamage (NumberValue) (zombie and soldiers only) — Defines how much health is lost by a victim when attacked by the NPC.
AttackDelay (NumberValue) (soldiers only) — Defines the minimum number of seconds between shots.
AttackMode (NumberValue) (soldiers only) — Specifies what the soldier will attack, based on the tagging system outlined below.
AttackRadius (NumberValue) (zombie and soldiers only) — Defines the maximum distance the NPC must be from a potential victim before it attempts to attack.
ClipCapacity (NumberValue) (soldiers only) — Defines how many bullets the soldier can fire before needing to reload.
ReloadDelay (NumberValue) (soldiers only) — Defines how many seconds must pass before the soldier's weapon clip is reloaded.

Assigning Tags

The NPC script uses CollectionService tags to manage aggression toward other characters and players. Various tags can be assigned as follows:

  • To assign tag(s) to another NPC, you can call CollectionService/AddTag|CollectionService:AddTag() from the Command Bar in Studio, where model is the NPC’s top-level Model and tag is the desired tag.
  • To assign a tag to a Player character, you can add a Script with a CollectionService/AddTag|CollectionService:AddTag() call to StarterCharacterScripts. For example:
Tag Purpose
SoldierEnemy / SoldierFriend Determines if a soldier, based on its AttackMode configuration value, should attack another character.
  • When the soldier's AttackMode is set to 1, other characters must be tagged with SoldierEnemy to be considered attackable (blacklist).
  • When the soldier's AttackMode is set to 2, all objects without the SoldierFriend tag are considered attackable (whitelist).
  • When the soldier's AttackMode is set to 3, these tags are ignored entirely and the soldier will attack all characters.
ZombieFriend This tag is used by the zombie to determine whether it should not attack a character (whitelist). When applied, the zombie becomes docile toward the tagged character.
  • npc
  • character
  • zombie
  • soldier
  • robot