Saturday, 4 May 2024
Kho Content

NPC Kit | Roblox Creator Documentation

Instructions and assets may have changed since the time this project kit was released. The content of this project and documentation can be used under Roblox’s Limited Use License.

Non-Player Characters (NPCs) 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 using a tag system to set behavior.

To use an NPC in your game:

  1. Select one of the following NPC kits:

    Drooling Zombie

    Soldiers

    RO-01 Robots

    NP-C 9000 Robots

  2. On the NPC’s item page, click the green Get button and confirm the transaction.

  3. In Roblox Studio, open the toolbox (View → Toolbox).

  4. Select your toolbox Inventory section.

  5. Locate the NPC and click it to add it into the place.

Character Structure

Each NPC model typically contains the following objects:

Object Name or [Type]
Type
DescriptionAnimations
Folder
Contains Animations

AttackAnimation

or

DeathAnimation

.Initial Poses
Folder
Contains posing information.

Animate

Script
Loads and plays animations on the character rig. See

Animate

for more details.[Accessory]
Accessory
One of possibly multiple AccessoriesHealth
Script
Typically regenerates the HumanoidHumanoid
Humanoid
Manages HumanoidHumanoid.HealthHumanoid.WalkSpeedHumanoid.DisplayDistanceTypeNPC
Script
Defines character-specific behaviors such as roaming, attacking, etc. Parents the following objects:

Maid

(ModuleScript

Ragdoll

(ModuleScriptModuleScriptRbxNpcSounds
Script
Defines and manages behavior related to character sound effects like running, dying, etc.

BodyParts

BasePart
Various character body parts attached to the HumanoidRootPart or neighboring body parts through Motor6D or constraint objects. See

BodyParts

for more details. HumanoidRootPart
BasePart
A special invisible part that’s considered the root of the rig; this is also the

PrimaryPart

of the character’s Model

Configuration

Configuration
Contains value objects which tune various behaviors. See

Configuration

for more details.

Square brackets [] refer to the object in general and the name doesn’t matter. For example, [Model] refers to the weapon’s Model and you can rename it to whatever makes sense.

Design Notes

When using the NPC kit, keep in mind the following 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 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 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 can create custom copies of existing animations, and to play animations under different conditions, you can edit the Animate or NPC scripts directly. For more information, see Animation.

Animate

The Animate Script in the NPC Model handles animation related configurations and contains the following objects:

Object Name or [Type]
Type
DescriptionScaleDampeningPercent
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. This object can parent any number of Animations

These Animations

Weight

(NumberValue

BodyParts

The BodyPart BasePart in the NPC Model represent the various character body parts and contains the following objects:

Object Name or [Type]
Type
DescriptionAvatarPartScaleType
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 ToolAccessory[Motor6D]
Motor6D
An animated joint between two body parts. Note that AnimatorMotor6DsMotor6Ds[Joint]
WeldConstraintConstraintJointInstance
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.

Configuration

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.

Object Name or [Type]
Type
DescriptionDestroyOnDeath
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
Defines how much health is lost by a victim when attacked by the NPC. This applies for Zombie and Soldier kits only.AttackDelay
NumberValue
Defines the minimum number of seconds between shots. This applies for Soldier kits only.AttackMode
NumberValue
Specifies what the soldier will attack, based on the

tagging system

. This applies for Soldier kits only.AttackRadius
NumberValue
Defines the maximum distance the NPC must be from a potential victim before it attempts to attack. This applies for Zombie and Soldier kits only.ClipCapacity
NumberValue
Defines how many bullets the soldier can fire before needing to reload. This applies for Soldier kits only.ReloadDelay
NumberValue
Defines how many seconds must pass before the soldier’s weapon clip is reloaded. This applies for Soldier kits only.

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() from the Command Bar in Studio, where model is the NPC’s top-level Model and tag is the desired tag.

    1

    game:GetService(

    "CollectionService"

    ):AddTag(model, tag)

    2

  • To assign a tag to a Player character, you can add a Script with a CollectionService:AddTag() call to StarterCharacterScripts. For example:

    1

    game:GetService(

    "CollectionService"

    ):AddTag(script.Parent,

    "SoldierEnemy"

    )

    2

The following are supported tags:

Tag
PurposeSoldierEnemy / 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.

Post Comment