Skip to main content

NPC

Inherits from DynamicInstance

NPC (non-player character) is an object similar to a Player but that can be controlled by code. Like players, it can walk and jump, and its body part colors can be customized.


Summary

Properties

Methods

Events


Properties

Anchored

NPC.Anchored: bool

Determines whether the NPC is affected by physics or not.


FaceID

NPC.FaceID: int

The face ID of the NPC's face.


Grounded

NPC.Grounded: bool

Returns true if the NPC is currently standing on the ground.


HeadColor

NPC.HeadColor: Color

Specifies the color of the NPC's head.


Health

NPC.Health: float

Specifies the current amount of health the NPC has.


MoveTarget

NPC.MoveTarget: Instance

Determines the instance the NPC should walk towards.


WalkSpeed

NPC.WalkSpeed: float

Determines the walkspeed of the NPC.


JumpPower

NPC.JumpPower: float

Determines the jump power of the NPC.


MaxHealth

NPC.MaxHealth: float=100

Specifies the maximum amount of health a NPC can have.


ShirtID

NPC.ShirtID: int

Specifies the shirt ID of the NPC's shirt.


PantsID

NPC.PantsID: int

The pants ID of the NPC's pants.


TorsoColor

NPC.TorsoColor: Color

Specifies the color of the NPC's torso.


LeftArmColor

NPC.LeftArmColor: Color

Specifies the color of the NPC's left arm.


RightArmColor

NPC.RightArmColor: Color

Specifies the color of the NPC's right arm.


LeftLegColor

NPC.LeftLegColor: Color

Specifies the color of the NPC's left leg.


RightLegColor

NPC.RightLegColor: Color

Specifies the color of the NPC's right leg.


NPC.NavDestinationDistance: float

Returns the remaining distance before the NPC reaches the end of its pathfind.


NPC.NavDestinationValid: bool

Returns whether or not the NPC has a valid path to its set destination.


NPC.NavDestinationReached: bool

Returns whether or not the NPC has reached the end of its pathfind.


Velocity

NPC.Velocity: Vector3

Returns or sets the velocity of the NPC.


Methods

LoadAppearance

NPC:LoadAppearance(userID: int)

Parameters:

ParameterTypeDefaultDescription
userIDint-

Loads the specified user ID's avatar on the NPC.

Example

-- Loads the appearance of willemsteller
npc:LoadAppearance(2)

ClearAppearance

NPC:ClearAppearance()

Clears the NPC's appearance.

Example

-- Clears the appearance of the NPC
npc:ClearAppearance()

SetNavDestination

NPC:SetNavDestination(position: Vector3)

Parameters:

ParameterTypeDefaultDescription
positionVector3-

Sets the destination for the NPC's pathfind.


Respawn

NPC:Respawn()

Respawns the NPC.


Jump

NPC:Jump()

Makes the NPC jump.


EquipTool

NPC:EquipTool(tool: Tool)

Parameters:

ParameterTypeDefaultDescription
toolTool-

Equips the specified tool on the NPC.


DropTool

NPC:DropTool()

Drops the tool currently equipped on the NPC.

Properties


Events

Died

NPC.Died()

Fires when the NPC dies.

Example

game["Environment"]["NPC"].Died:Connect(function ()
print("NPC died!")
end)

Methods