Humanoid

Show Deprecated

The Humanoid is a special object that gives models the functionality of a character. It grants the model with the ability to physically walk around and interact with various components of a Roblox level. Humanoids are always parented inside of a Model, and the model is expected to be an assembly of BasePart and Motor6D; the root part of the assembly is expected to be named HumanoidRootPart. It also expects a part named Head to be connected to the character's torso part, either directly or indirectly. By default, there are two official types of character rigs supplied by Roblox, each with their own set of rules:

R6

  • A basic character rig that uses 6 parts for limbs.
  • The Head part must be attached to a part named Torso, or the Humanoid will die immediately.
  • BodyPart appearances are applied using CharacterMesh objects.
  • Certain properties, such as Humanoid.LeftLeg and Humanoid.RightLeg, only work with R6.

R15

  • More complex than R6, but also far more flexible and robust.
  • Uses 15 parts for limbs.
  • The Head part must be attached to a part named UpperTorso or the Humanoid will die immediately.
  • BodyPart appearances have to be assembled directly.
  • Can be dynamically rescaled by using special NumberValue objects parented inside of the Humanoid.
  • The Humanoid will automatically create Vector3Value objects named OriginalSize inside of each limb.
  • If a NumberValue is parented inside of the Humanoid and is named one of the following, it will be used to control the scaling functionality:
    • BodyDepthScale
    • BodyHeightScale
    • BodyWidthScale
    • HeadScale

Code Samples

Walking Camera Bobble Effect

1local RunService = game:GetService("RunService")
2
3local playerModel = script.Parent
4local humanoid = playerModel:WaitForChild("Humanoid")
5
6local function updateBobbleEffect()
7 local now = tick()
8 if humanoid.MoveDirection.Magnitude > 0 then -- Is the character walking?
9 local velocity = humanoid.RootPart.Velocity
10 local bobble_X = math.cos(now * 9) / 5
11 local bobble_Y = math.abs(math.sin(now * 12)) / 5
12
13 local bobble = Vector3.new(bobble_X, bobble_Y, 0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed)
14 humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, 0.25)
15 else
16 -- Scale down the CameraOffset so that it shifts back to its regular position.
17 humanoid.CameraOffset = humanoid.CameraOffset * 0.75
18 end
19end
20
21RunService.RenderStepped:Connect(updateBobbleEffect)

Summary

Properties

Sets whether the character will automatically jump when they hit an obstacle as a player on a mobile device.

AutoRotate sets whether or not the Humanoid will automatically rotate to face in the direction they are moving in.

When Enabled, AutomaticScalingEnabled causes the size of the character to change in response to the values in the Humanoid's child scale values changing.

Determines whether a Humanoid's joints break when in the Dead state.

An offset applied to the Camera's subject position when its CameraSubject is set to this Humanoid.

Controls the distance behavior of the humanoid's name and health display.

Sets the text of a Humanoid, displayed above their head.

Describes the Material that the Humanoid is currently standing on. If the Humanoid isn't standing on anything, the value of this property will be Air.

READ ONLY
NOT REPLICATED

Describes the current health of the Humanoid on the range [0, Humanoid.MaxHealth].

NOT REPLICATED

Used in conjunction with the Humanoid.DisplayDistanceType property to control the distance from which a humanoid's health bar can be seen.

Controls when the humanoid's health bar is allowed to be displayed.

Determines the distance off the ground the Humanoid.RootPart should be.

If true, the Humanoid jumps with an upwards force equal to the value of its Humanoid.JumpPower property or the height of Humanoid.JumpHeight, depending on the value of Humanoid.UseJumpPower.

NOT REPLICATED

Provides control over the height that the Humanoid jumps to.

Determines how much upwards force is applied to the Humanoid when jumping.

The maximum value of a Humanoid's Humanoid.Health.

The maximum slope angle that a humanoid can walk on without slipping.

Describes the direction that the Humanoid is walking in.

READ ONLY
NOT REPLICATED

Used in conjunction with the Humanoid.DisplayDistanceType property to control the distance from which a humanoid's name can be seen.

Controls whether a humanoid's name and health bar can be seen behind walls or other objects.

Determines whether the Humanoid is currently in the PlatformStanding HumanoidStateType.

Allows developers to disable the behavior where a player Character|character dies if the Neck Motor6D is removed or disconnected even momentarily.

Describes whether this Humanoid is utilizing the legacy R6 character rig, or the new R15 character rig.

A reference to the humanoid's HumanoidRootPart object.

READ ONLY
NOT REPLICATED

A reference to the seat that a Humanoid is currently sitting in, if any.

READ ONLY
NOT REPLICATED

Describes whether the Humanoid is currently sitting.

Describes the 3D position where the Player controlling the Humanoid last clicked in the world while using a Tool.

Determines whether the JumpHeight (false) or Humanoid.JumpPower (true) property is used.

Describes the Humanoid's maximum movement speed in studs/sec.

A reference to a part whose position is trying to be reached by a humanoid.

The position that a humanoid is trying to reach, after a call to Humanoid:MoveTo() is made.

Events


Fires when the speed at which a Humanoid is climbing changes.


Fires when the Humanoid dies.

EmoteTriggered(success: boolean, animationTrack: AnimationTrack): RBXScriptSignal  



Fires when the Humanoid enters or leaves the FallingDown HumanoidStateType.


Fires when the Humanoid enters or leaves the Freefall HumanoidStateType.


Fires when the Humanoid enters or leaves the GettingUp HumanoidStateType.


Fires when the Humanoid.Health changes (or when the Humanoid.MaxHealth is set).


Fires when the Humanoid enters and leaves the Jumping HumanoidStateType.


Fires when the Humanoid finishes walking to a goal declared by Humanoid:MoveTo().


Fires when the Humanoid enters or leaves the PlatformStanding HumanoidStateType.


Fires when the Humanoid enters or leaves the Ragdoll HumanoidStateType.


Fires when the speed at which a Humanoid is running changes.

Seated(active: boolean, currentSeatPart: BasePart): RBXScriptSignal  

Fired when a Humanoid either sits in a Seat or VehicleSeat or gets up.


Fired when the state of the Humanoid is changed.


Fires when the Humanoid enters or leaves the StrafingNoPhysics HumanoidStateType.


Fires when the speed at which a Humanoid is swimming in Terrain water changes.

Touched(touchingPart: BasePart, humanoidPart: BasePart): RBXScriptSignal  

Fires when one of the Humanoid's limbs come in contact with another BasePart.

Methods

AddAccessory(accessory: Instance): void  

Attaches the specified Accessory to the Humanoid's parent.

ApplyDescriptionBlocking(humanoidDescription: HumanoidDescription): void  



Assembles a tree of Motor6D joints by attaching together Attachment objects in a Humanoid's character.

CacheDefaults(): void  


ChangeState(state: HumanoidStateType): void  

Set the Humanoid to enter the given HumanoidStateType.

EquipTool(tool: Instance): void  

Makes the Humanoid equip the given Tool.


Returns an array of Accessories that the Humanoid's parent is currently wearing.


Returns back a copy of the Humanoid's cached HumanoidDescription, which describes its current look.


Pass a body part to this function (the body part should be a sibling of Humanoid, and a child of a Model) to get the BodyPartR15 of the Part.

GetLimb(part: Instance): Limb  

Returns the Limb enum that is associated with the given Part.


Returns whether a HumanoidStateType is enabled for the Humanoid.

Move(moveDirection: Vector3, relativeToCamera: boolean): void  

Causes the Humanoid to walk in the given direction.

MoveTo(location: Vector3, part: Instance): void  

Causes the Humanoid to attempt to walk to the given location by setting the Humanoid.WalkToPoint and Humanoid.WalkToPart properties.

RemoveAccessories(): void  

Removes all Accessories worn by the Humanoid's parent.


Dynamically replaces a Humanoid body part with a different part.

SetClickToWalkEnabled(enabled: boolean): void  


SetStateEnabled(state: HumanoidStateType, enabled: boolean): void  

Sets whether a given HumanoidStateType is enabled for the Humanoid.

TakeDamage(amount: number): void  

Lowers the Humanoid.Health of the Humanoid by the given amount if it is not protected by a ForceField.

UnequipTools(): void  

Unequips any Tool currently equipped by the Humanoid.

ApplyDescription(humanoidDescription: HumanoidDescription, assetTypeVerification: AssetTypeVerification): void  YIELDS

Makes the character's look match that of the passed in HumanoidDescription.

ApplyDescriptionClientServer(humanoidDescription: HumanoidDescription): void  YIELDS


ApplyDescriptionReset(humanoidDescription: HumanoidDescription, assetTypeVerification: AssetTypeVerification): void  YIELDS

Makes the character's look match that of the passed in HumanoidDescription (even after external changes).

PlayEmote(emoteName: string): boolean  YIELDS

Plays emotes and returns if was successfully ran.

Properties

AutoJumpEnabled

AutoJumpEnabled sets whether or not the Humanoid will attempt to automatically jump over an obstacle it is walking towards.

Currently, this property only works when the following conditions are true:

  • The Humanoid's character model is the Player.Character of a Player.
  • The Player in question is using touch controls.

When a player's character spawns, the property's value matches the player's Player.AutoJumpEnabled property - which in turn matches the StarterPlayer.AutoJumpEnabled property.

AutoRotate

The AutoRotate property describes whether or not the Humanoid will automatically rotate to face in the direction they are moving. When set to true, the character model will gradually turn to face their movement direction as the Humanoid walks around. When set to false, the character model will remain fixated in its current rotation, unless a rotating force is applied to the HumanoidRootPart.

If the character model happens to be the character of a player, then the behavior of the Humanoid's rotation is influenced by the UserGameSetting's RotateType property.

When the AutoRotate property is set to true, the RotateType property has the following effects on the Humanoid's rotation:

RotationTypeBehaviorContext
CameraRelativeCharacter will rotate to face in the direction of the camera.Player has their camera zoomed into first-person, or they are in shift-lock mode.
CameraRelativeCharacter will rotate to face in the direction of the camera.Player has their camera zoomed into first-person, or they are in shift-lock mode.

AutomaticScalingEnabled

The Humanoid has six child scale values including BodyDepthScale, BodyHeightScale, BodyProportionScale, BodyTypeScale, BodyWidthScale, HeadScale. Changing the value of any of these causes the character's body parts and accessories to change size, but only if AutomaticScalingEnabled is true.

BreakJointsOnDeath

Determines whether a Humanoid's joints break when in the Dead state. Defaults to true.

If it is set to false, BreakJoints will not be called on death or after death. If it is set to true, the existing break-joints-every-frame behavior will be used.

CameraOffset

The CameraOffset property specifies an offset to the Camera's subject position when its Camera.CameraSubject is set to this Humanoid.

The offset is applied in object-space, relative to the orientation of the Humanoid's HumanoidRootPart. For example, an offset Vector3 value of (0, 10, 0) offsets the player's camera to 10 studs above the player's humanoid.

DisplayDistanceType

The DisplayDistanceType property controls the distance behavior of the humanoid's name and health display. This property is set using the HumanoidDisplayDistanceType enum with three available values, each with their own set of rules:

  • When set to Viewer, the humanoid sees the name/health of other humanoids within range of its own NameDisplayDistance and HealthDisplayDistance.
  • When set to Subject, the humanoid takes full control over its own name and health display through its NameDisplayDistance and HealthDisplayDistance values.
  • When set to None, the humanoid's name and health bar do not appear under any circumstances.

See Character Name/Health Display for an in-depth guide on controlling the appearance of character names and health bars.

DisplayName

DisplayName is a property that determines the Humanoid's name display when visible. By default, a new Humanoid will have the value of an empty string. If DisplayName is an empty string, the humanoid's name display will default to the humanoid's parent's name property.

Player Character Loading When players load their character, either automatically or through the use of LoadCharacter(), the Humanoid that is created by the engine will have its DisplayName property set to the player's DisplayName property.

StarterCharacter and StarterHumanoid When a Humanoid named StarterHumanoid is parented to StarterPlayer, or when a Humanoid is present in a Model named StarterCharacter, the DisplayName property will be respected when Characters are loaded by Players in the game. The engine will only override the DisplayName property of the Humanoid with the DisplayName property of the player if the StarterHumanoid's DisplayName property is an empty string.

EvaluateStateMachine

Not Browsable

FloorMaterial

Read Only
Not Replicated

This is a read-only property that describes the Material the Humanoid is currently standing on. It works with both regular Parts and Terrain voxels.

The code sample below demonstrates how to listen to when this property changes using Instance:GetPropertyChangedSignal(). When the material the humanoid is standing on changes, it will print a message indicating the new material being stood on.


1local Humanoid = route.to.humanoid
2
3Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
4 print("New value for FloorMaterial: " .. tostring(Humanoid.FloorMaterial))
5end)
6

Caveats

  • When the Humanoid is not standing on a floor, the value of this property will be set to Air.
    • This occurs because Enum properties cannot have an empty value.
    • This can cause some confusion if a part has its material is set to Air, though in practice, parts are not supposed to use that material in the first place.
  • The character model of the Humanoid must be able to collide with the floor, or else it will not be detected.

Health

Not Replicated

Health is a property that represents the current health of the Humanoid. The value is restricted to the range [0, Humanoid.MaxHealth]. If the Humanoid is dead, Health is continually set to 0.

Dealing Damage

The TakeDamage function should be used to subtract from Health. If a Humanoid has a ForceField as a sibling, the function will not lower Health.

Regeneration

If there is no Script named "Health" within StarterCharacterScripts, a passive health regeneration script is automatically inserted. This causes players' characters to spawn with the same health regeneration script, which adds 1% of MaxHealth to Health each second, while the Humanoid is not dead. To disable this health regeneration behavior, add an empty Script named "Health" to StarterCharacterScripts.

Health Bar Display

When Health is less than MaxHealth, a health bar is displayed under the Humanoid's name in-game. The display behavior of the health bar is dependent on the HealthDisplayDistance and HealthDisplayType.

A Player will not see their own name and health bar above their Character. Instead, it is displayed in the top right corner of the screen on the top bar. The health bar is visible when Health is less than MaxHealth.

Death

When the value of the character's health reaches 0, the Humanoid automatically transitions to the Dead HumanoidStateType. In this state, Health is locked to 0; however, there is no error or warning for setting the Health of a dead Humanoid to a positive nonzero value.

HealthDisplayDistance

The HealthDisplayDistance property is a number used in conjunction with the Humanoid.DisplayDistanceType property to control the distance from which a humanoid's health bar can be seen.

See Character Name/Health Display for an in-depth guide on controlling the appearance of character names and health bars.

HealthDisplayType

HealthDisplayType controls when a humanoid's health bar is allowed to be displayed. By default, this property is set to DisplayWhenDamaged, which makes the health bar only display when a humanoid's Humanoid.Health is less than its Humanoid.MaxHealth. It can also be set to AlwaysOn, which makes the health bar always display, or AlwaysOff, which prevents it from ever displaying.

This property functions independently of the humanoid's HealthDisplayDistance property, which is responsible for making the health bar fade out at certain distances. If HealthDisplayType is set to AlwaysOn, it will still fade out depending the how Humanoid.HealthDisplayDistance is configured.

See Character Name/Health Display for an in-depth guide on controlling the appearance of character names and health bars.

HipHeight

HipHeight determines the distance (in studs) off the ground the Humanoid.RootPart should be when the Humanoid is standing. The RigType influences the way this property behaves:

HipHeight for R15 Humanoids

With R15 rigs, a suitable HipHeight is preset to ensure the height of the Humanoid.RootPart is correct. The height of the legs is not used. The overall height of the Humanoid can be described in the following formula:


1Height = (0.5 * RootPart.Size.Y) + HipHeight
2

HipHeight for R6 Humanoids

For R6 rigs, the RootPart's height is determined by the height of the character's legs and Humanoid.RootPart. HipHeight instead describes a relative offset. The overall height of the Humanoid can be described in the following formula:


1Height = LeftLeg.Size.Y + (0.5 * RootPart.Size.Y) + HipHeight
2
Not Replicated

If true, the Humanoid jumps with an upwards force equal to the value of its Humanoid.JumpPower property or the height of Humanoid.JumpHeight, depending on the value of Humanoid.UseJumpPower.

If Humanoid.UseJumpPower is set to true, Humanoids are able to jump roughly 7.2 studs high by default, depending on both the Workspace's Workspace.Gravity, and the Humanoid.JumpPower of the humanoid itself.

If Humanoid.UseJumpPower is set to false, the height of the jump can be set explicitly with Humanoid.JumpHeight.

JumpHeight

Provides control over the height a Humanoid jumps in studs. The starting value of this property is determined by the value of StarterPlayer.CharacterJumpHeight, which defaults to 7.2.

This property is only visible in the Properties window if Humanoid.UseJumpPower is set to false, as it would not be relevant otherwise.

This property can be used to adjust the height that a humanoid can jump, allowing developers to remove jumping, allow dynamically adjustable jump height based on character stats or raise the jump height (as if on the moon or such).

JumpPower

Determines how much upwards force is applied to the Humanoid when jumping. The starting value of this property is determined by the value of StarterPlayer.CharacterJumpPower, which defaults to 50 and is constrained between 0 and 1000.

This property is only visible in the Properties window if `Class.Humanoid.UseJumpPower`` is set to true, as it would not be relevant otherwise.

Note:

  • Jumps are also influenced by the Workspace.Gravity property which determines the acceleration due to gravity.
  • Although setting this property to 0 will prevent the Humanoid from jumping, developers are advised to disable the "Jumping" state using the Humanoid:SetStateEnabled() function.

MaxHealth

The maximum value of a Humanoid's Humanoid.Health. The value of this property is used with the value of the Humanoid.Health property to size the default health bar display.

When a Humanoid's Humanoid.Health reaches its maximum value, its health bar may not be displayed anymore, depending on its Humanoid.HealthDisplayType property, as seen below:

MaxSlopeAngle

This property determines the maximum slope angle that a humanoid can climb. If the angle of a slope is greater than a humanoid's MaxSlopeAngle, they will slide down the slope.

When a character spawns, this property is set according to the value of StarterPlayer.CharacterMaxSlopeAngle.

The value of this property is constrained to values between 0° and 89°. It defaults to 89°, so humanoids can climb pretty much any slope they want by default.

MoveDirection

Read Only
Not Replicated

MoveDirection is a read-only property that describes the direction a Humanoid is walking in, as a unit vector or zero length vector. The direction is described in world space.

Because this property is read-only, it cannot be set by a Script or LocalScript.

NameDisplayDistance

The NameDisplayDistance property is a number used in conjunction with the Humanoid.DisplayDistanceType property to control the distance from which a humanoid's name can be seen.

See Character Name/Health Display for an in-depth guide on controlling the appearance of character names and health bars.

NameOcclusion

Controls whether a humanoid's name and health bar can be seen behind walls or other objects. This property is a NameOcclusion value and can be configured to occlude all names, enemy names, or disable occlusion entirely.

In cases where the LocalPlayer has no Humanoid associated with it, this property instead applies to the subject Humanoid.

See Character Name/Health Display for an in-depth guide on controlling the appearance of character names and health bars.

PlatformStand

PlatformStand describes whether the Humanoid is currently in the PlatformStanding HumanoidStateType. When true, the Humanoid is in a state where it is free-falling and cannot move. This state behaves similar to sitting, except that jumping does not free the humanoid from the state.

The now-deprecated SkateboardPlatform puts the Humanoid into this state, much like how a Seat causes a sitting state.

RequiresNeck

Allows developers to disable the behavior where a player Character|character dies if the Neck Motor6D is removed or disconnected even momentarily. This property defaults to true.

RigType describes whether a Humanoid is utilizing the legacy R6 character rig, or the newer R15 character rig.

The R6 rig uses 6 visible Parts while the R15 rig uses 15 visible Parts. R15 rigs have more joints than R6 rigs, making them much more versatile when being animated.

Note that if this property is set incorrectly, the Humanoid will not function correctly. For example, if a R15 humanoid's RigType is set to R6, the Humanoid will die as there is no BasePart called Torso connected to a BasePart called Head.

RootPart

Read Only
Not Replicated

A reference to the humanoid's HumanoidRootPart object, the root driving part of the Humanoid that controls a humanoid's movement through the 3D world. This part is normally invisible.

HumanoidRootPart made visible

Note that in the case of player characters, RootPart is the same as the Model.PrimaryPart of the Player.Character model.

SeatPart

Read Only
Not Replicated

SeatPart is a reference to the seat that a Humanoid is currently sitting in, if any. The value of this property can be either a Seat, or a VehicleSeat. It will be nil if the Humanoid is not currently sitting in a seat.

Note:

The Sit property is a boolean that indicates whether the Humanoid is currently sitting. Humanoids can be forced into a sitting state by setting this property's value to true. If the Humanoid isn't attached to a seat while in its sitting state, it will trip over with no collision in its legs. A Humanoid can escape from the sitting state by jumping.

Note:

TargetPoint

Do not use This property only works with Experimental Mode enabled, which has been entirely discontinued.

This property describes a 3D position in space where the Player controlling this Humanoid last clicked with a Tool equipped.

This property is primarily used by classic tools to determine what a humanoid is targeting when they activate a tool. If you give an NPC a classic rocket launcher, set their TargetPoint, and then call the tool's Tool:Activate() function, you can make the NPC fire a rocket at the target point.

UseJumpPower

When a character spawns, this property is set according to the value of StarterPlayer.CharacterUseJumpPower which defaults to true.

When a character spawns, this property is set according to the value of StarterPlayer.CharacterUseJumpPower which defaults to true.

When jumping, with this set to true, the Humanoid.JumpHeight value is used to ensure the humanoid jumps to that height. With this set to false, the Humanoid.JumpPower value is used to apply an upward force.

WalkSpeed

WalkSpeed is a property that describes how quickly this Humanoid is able to walk, in studs per second. This property defaults to the value of StarterPlayer.CharacterWalkSpeed, which defaults to 16, meaning a Roblox Player.Character can move 16 studs in any direction each second by default.

Note:

  • When controlled on a mobile device or a gamepad, a humanoid can walk slower than their WalkSpeed if the controlling joystick is moved closer to its center
  • Roblox's default animation script scales a humanoid's movement animations based on how fast it is moving relative to the default speed of 16 studs/sec
  • The speed the Humanoid is currently walking at can be obtained using the Humanoid.Running event
  • Movement speed is reduced to 87.5% WalkSpeed when swimming and 70% WalkSpeed when climbing

WalkToPart

WalkToPart is a reference to a part that the Humanoid is trying to reach. This property is normally set when a part is passed as the 2nd argument of the Humanoid's Humanoid:MoveTo() function.

When WalkToPart is set and a humanoid is actively trying to reach the part, it will keep updating its Vector3 goal to be the position of the part, plus the Humanoid.WalkToPoint translated in object space relative to the rotation of the part.

This can be described in Lua as:


1goal = humanoid.WalkToPart.CFrame:pointToObjectSpace(humanoid.WalkToPoint)
2

Caveats

  • Setting the value of WalkToPart isn't sufficient enough to make a humanoid start following a part.
  • The Humanoid is prompted to start attempting to reach a goal when the value of WalkToPoint is changed.
  • This may be changed in the future.
  • The reach goal state of a humanoid will timeout after 8 seconds if it doesn't reach its goal.
  • This is done so that NPCs won't get stuck waiting for Humanoid.MoveToFinished to fire.
  • If you don't want this to happen, you should repeatedly call MoveTo so that the timeout will keep resetting.

WalkToPoint

WalkToPoint describes the 3D position in space that a humanoid is trying to reach, after having been prompted to do so by the Humanoid's Humanoid:MoveTo() function.

If a humanoid's Humanoid.WalkToPart is set, the goal is set by transforming WalkToPoint relative to the parts position and rotation. If WalkToPart is not set, then the humanoid will try to reach the 3D position specified by WalkToPoint directly.

Caveats

  • The value of WalkToPoint must be changed to a different value in order for the humanoid to start walking towards it.
  • If you want to make a humanoid walk to 0,0,0, you should use the Humanoid's MoveTo function.
  • This may be changed in the future.
  • The reach goal state of a humanoid will timeout after 8 seconds if it doesn't reach its goal.
  • This is done so that NPCs won't get stuck waiting for Humanoid.MoveToFinished to fire.
  • If you don't want this to happen, you should repeatedly call MoveTo so that the timeout will keep resetting.

Events

Climbing

Fires when the speed at which a Humanoid is climbing changes.

Humanoids can climb up ladders made out of Parts or TrussParts.

Humanoids climb at 70% of their Humanoid.WalkSpeed.

This event will not always fire with a speed of 0 when the Humanoid stops climbing.

See also:

Parameters

speed: number

The speed at which the Humanoid is currently climbing.


Code Samples

Humanoid.Climbing

1local Players = game:GetService("Players")
2
3local function onCharacterClimbing(character, speed)
4 print(character.Name, "is climbing at a speed of", speed, "studs / second.")
5end
6
7local function onCharacterAdded(character)
8 character.Humanoid.Climbing:Connect(function(speed)
9 onCharacterClimbing(character, speed)
10 end)
11end
12
13local function onPlayerAdded(player)
14 player.CharacterAdded:Connect(onCharacterAdded)
15end
16
17Players.PlayerAdded:Connect(onPlayerAdded)

ClusterCompositionFinished

Roblox Script Security

Died

This event fires when the Humanoid dies, usually when Humanoid.Health reaches 0. This could be caused either by disconnecting their head from their Humanoid.Torso, or directly setting the health property.

This event only fires if the Humanoid is a descendant of the Workspace. If the Dead HumanoidStateType is disabled it will not fire.


Code Samples

Humanoid.Died

1local Players = game:GetService("Players")
2
3local function onPlayerAdded(player)
4 local function onCharacterAdded(character)
5 local humanoid = character:WaitForChild("Humanoid")
6
7 local function onDied()
8 print(player.Name, "has died!")
9 end
10
11 humanoid.Died:Connect(onDied)
12 end
13
14 player.CharacterAdded:Connect(onCharacterAdded)
15end
16
17Players.PlayerAdded:Connect(onPlayerAdded)

EmoteTriggered

Roblox Script Security

Parameters

success: boolean
animationTrack: AnimationTrack

FallingDown

The FallingDown event fires when the Humanoid enters and leaves the FallingDown HumanoidStateType.

The Humanoid will enter the GettingUp state 3 seconds after the FallingDown state is enabled. When this happens this event will fire with an active value of false, and Humanoid.GettingUp will fire with an active value of true.

Parameters

active: boolean

Describes whether the Humanoid is entering or leaving the FallingDown HumanoidStateType.


Code Samples

Humanoid action events

1local character = script.Parent
2
3local humanoid = character:WaitForChild("Humanoid")
4
5humanoid.Climbing:Connect(function(speed)
6 print("Climbing speed: ", speed)
7end)
8
9humanoid.FallingDown:Connect(function(isActive)
10 print("Falling down: ", isActive)
11end)
12
13humanoid.GettingUp:Connect(function(isActive)
14 print("Getting up: ", isActive)
15end)
16
17humanoid.Jumping:Connect(function(isActive)
18 print("Jumping: ", isActive)
19end)
20
21humanoid.PlatformStanding:Connect(function(isActive)
22 print("PlatformStanding: ", isActive)
23end)
24
25humanoid.Ragdoll:Connect(function(isActive)
26 print("Ragdoll: ", isActive)
27end)
28
29humanoid.Running:Connect(function(speed)
30 print("Running speed: ", speed)
31end)
32
33humanoid.Strafing:Connect(function(isActive)
34 print("Strafing: ", isActive)
35end)
36
37humanoid.Swimming:Connect(function(speed)
38 print("Swimming speed: ", speed)
39end)

FreeFalling

This event fires when the Humanoid enters or leaves the Freefall HumanoidStateType.

The active parameter represents whether the Humanoid is entering or leaving the Freefall state.

Although the Freefall state generally ends when the Humanoid reaches the ground, this event may fire with active equal to false if the state is changed while the Humanoid is falling. For this reason, you should use Humanoid.StateChanged and listen for the Landed state to work out when a Humanoid has landed.

Parameters

active: boolean

Whether the Humanoid is entering or leaving the Freefall HumanoidStateType.


Code Samples

Humanoid action events

1local character = script.Parent
2
3local humanoid = character:WaitForChild("Humanoid")
4
5humanoid.Climbing:Connect(function(speed)
6 print("Climbing speed: ", speed)
7end)
8
9humanoid.FallingDown:Connect(function(isActive)
10 print("Falling down: ", isActive)
11end)
12
13humanoid.GettingUp:Connect(function(isActive)
14 print("Getting up: ", isActive)
15end)
16
17humanoid.Jumping:Connect(function(isActive)
18 print("Jumping: ", isActive)
19end)
20
21humanoid.PlatformStanding:Connect(function(isActive)
22 print("PlatformStanding: ", isActive)
23end)
24
25humanoid.Ragdoll:Connect(function(isActive)
26 print("Ragdoll: ", isActive)
27end)
28
29humanoid.Running:Connect(function(speed)
30 print("Running speed: ", speed)
31end)
32
33humanoid.Strafing:Connect(function(isActive)
34 print("Strafing: ", isActive)
35end)
36
37humanoid.Swimming:Connect(function(speed)
38 print("Swimming speed: ", speed)
39end)

GettingUp

This event fires when the Humanoid enters or leaves the GettingUp HumanoidStateType.

The GettingUp HumanoidStateType is a transition state that is activated shortly after the Humanoid enters the FallingDown (3 seconds) or Ragdoll (1 second) HumanoidStateTypes.

When a Humanoid attempts to get back up, this event will first fire with an active parameter of true before shortly after firing again with an active parameter of false.

See also:

Parameters

active: boolean

Whether the Humanoid is entering or leaving the GettingUp HumanoidStateType.


Code Samples

Humanoid action events

1local character = script.Parent
2
3local humanoid = character:WaitForChild("Humanoid")
4
5humanoid.Climbing:Connect(function(speed)
6 print("Climbing speed: ", speed)
7end)
8
9humanoid.FallingDown:Connect(function(isActive)
10 print("Falling down: ", isActive)
11end)
12
13humanoid.GettingUp:Connect(function(isActive)
14 print("Getting up: ", isActive)
15end)
16
17humanoid.Jumping:Connect(function(isActive)
18 print("Jumping: ", isActive)
19end)
20
21humanoid.PlatformStanding:Connect(function(isActive)
22 print("PlatformStanding: ", isActive)
23end)
24
25humanoid.Ragdoll:Connect(function(isActive)
26 print("Ragdoll: ", isActive)
27end)
28
29humanoid.Running:Connect(function(speed)
30 print("Running speed: ", speed)
31end)
32
33humanoid.Strafing:Connect(function(isActive)
34 print("Strafing: ", isActive)
35end)
36
37humanoid.Swimming:Connect(function(speed)
38 print("Swimming speed: ", speed)
39end)

HealthChanged

This event fires when the Humanoid.Health changes. However, it will not fire if the health is increasing from a value equal to or greater than the Humanoid.MaxHealth.

When Humanoid.Health reaches zero, the Humanoid will die and the Humanoid.Died event will fire. This event will fire with a value of zero.

Parameters

health: number

The new value of Humanoid.Health.


Code Samples

Humanoid.HealthChanged

1local Players = game:GetService("Players")
2
3local player = Players.LocalPlayer
4
5local function onCharacterAdded(character)
6 local humanoid = character:WaitForChild("Humanoid")
7 local currentHealth = humanoid.Health
8
9 local function onHealthChanged(health)
10 local change = math.abs(currentHealth - health)
11 print("The humanoid's health", (currentHealth > health and "decreased by" or "increased by"), change)
12 currentHealth = health
13 end
14
15 humanoid.HealthChanged:Connect(onHealthChanged)
16end
17
18player.CharacterAdded:Connect(onCharacterAdded)
Health Bar

1local Players = game:GetService("Players")
2
3local player = Players.LocalPlayer
4
5-- Paste script into a LocalScript that is
6-- parented to a Frame within a Frame
7local frame = script.Parent
8local container = frame.Parent
9container.BackgroundColor3 = Color3.new(0, 0, 0) -- black
10
11-- This function is called when the humanoid's health changes
12local function onHealthChanged()
13 local human = player.Character.Humanoid
14 local percent = human.Health / human.MaxHealth
15 -- Change the size of the inner bar
16 frame.Size = UDim2.new(percent, 0, 1, 0)
17 -- Change the color of the health bar
18 if percent < 0.1 then
19 frame.BackgroundColor3 = Color3.new(1, 0, 0) -- black
20 elseif percent < 0.4 then
21 frame.BackgroundColor3 = Color3.new(1, 1, 0) -- yellow
22 else
23 frame.BackgroundColor3 = Color3.new(0, 1, 0) -- green
24 end
25end
26
27-- This function runs is called the player spawns in
28local function onCharacterAdded(character)
29 local human = character:WaitForChild("Humanoid")
30 -- Pattern: update once now, then any time the health changes
31 human.HealthChanged:Connect(onHealthChanged)
32 onHealthChanged()
33end
34
35-- Connect our spawn listener; call it if already spawned
36player.CharacterAdded:Connect(onCharacterAdded)
37if player.Character then
38 onCharacterAdded(player.Character)
39end

Jumping

This event fires when the Humanoid enters and leaves the Jumping HumanoidStateType.

When a Humanoid jumps this will fire with a active parameter of true before shortly afterwards firing again with an active parameter of false. This does not correspond with when a Humanoid has landed. For that, developers should listen for the Landed HumanoidStateType using Humanoid.StateChanged.

You can disable jumping using the Humanoid:SetStateEnabled() function.

Parameters

active: boolean

Whether the Humanoid is entering or leaving the Jumping HumanoidStateType.


Code Samples

Humanoid action events

1local character = script.Parent
2
3local humanoid = character:WaitForChild("Humanoid")
4
5humanoid.Climbing:Connect(function(speed)
6 print("Climbing speed: ", speed)
7end)
8
9humanoid.FallingDown:Connect(function(isActive)
10 print("Falling down: ", isActive)
11end)
12
13humanoid.GettingUp:Connect(function(isActive)
14 print("Getting up: ", isActive)
15end)
16
17humanoid.Jumping:Connect(function(isActive)
18 print("Jumping: ", isActive)
19end)
20
21humanoid.PlatformStanding:Connect(function(isActive)
22 print("PlatformStanding: ", isActive)
23end)
24
25humanoid.Ragdoll:Connect(function(isActive)
26 print("Ragdoll: ", isActive)
27end)
28
29humanoid.Running:Connect(function(speed)
30 print("Running speed: ", speed)
31end)
32
33humanoid.Strafing:Connect(function(isActive)
34 print("Strafing: ", isActive)
35end)
36
37humanoid.Swimming:Connect(function(speed)
38 print("Swimming speed: ", speed)
39end)

MoveToFinished

This event fires when the Humanoid finishes walking to a goal declared by the Humanoid.WalkToPoint and Humanoid.WalkToPart properties.

The Humanoid.WalkToPoint and Humanoid.WalkToPart properties can be set individually, or using the Humanoid:MoveTo() function.

If the Humanoid reaches its goal within 8 seconds, this event will return with reached as true. If the goal is not reached within 8 seconds the Humanoid will stop walking and reached will be false. This timeout can be reset be calling Humanoid:MoveTo() again within the timeout period.

Parameters

reached: boolean

A boolean indicating whether the Humanoid reached is goal. True if the Humanoid is reached its goal, false if the walk timed out before the goal could be reached.


Code Samples

Humanoid MoveTo Without Time out

1local function moveTo(humanoid, targetPoint, andThen)
2 local targetReached = false
3
4 -- listen for the humanoid reaching its target
5 local connection
6 connection = humanoid.MoveToFinished:Connect(function(reached)
7 targetReached = true
8 connection:Disconnect()
9 connection = nil
10 if andThen then
11 andThen(reached)
12 end
13 end)
14
15 -- start walking
16 humanoid:MoveTo(targetPoint)
17
18 -- execute on a new thread so as to not yield function
19 task.spawn(function()
20 while not targetReached do
21 -- does the humanoid still exist?
22 if not (humanoid and humanoid.Parent) then
23 break
24 end
25 -- has the target changed?
26 if humanoid.WalkToPoint ~= targetPoint then
27 break
28 end
29 -- refresh the timeout
30 humanoid:MoveTo(targetPoint)
31 task.wait(6)
32 end
33
34 -- disconnect the connection if it is still connected
35 if connection then
36 connection:Disconnect()
37 connection = nil
38 end
39 end)
40end
41
42local function andThen(reached)
43 print((reached and "Destination reached!") or "Failed to reach destination!")
44end
45
46moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)

PlatformStanding

This event fires when the Humanoid enters or leaves the PlatformStanding HumanoidStateType.

Whilst the Humanoid is in the PlatformStanding state, the Humanoid.PlatformStand property will be true.

Whilst Humanoid.PlatformStand is set to true, the Humanoid will be unable to move. For more information please see the page for Humanoid.PlatformStand.

The PlatformStand HumanoidStateType was associated with the now disabled Platform part. Despite this, it can still be used by developers.

Parameters

active: boolean

Whether the Humanoid is entering or leaving the PlatformStanding HumanoidStateType.


Code Samples

Humanoid.PlatformStanding

1local Players = game:GetService("Players")
2
3local player = Players.LocalPlayer
4
5local character = player.Character or player.CharacterAdded:Wait()
6local humanoid = character:WaitForChild("Humanoid")
7
8local function onPlatformStanding(isPlatformStanding)
9 if isPlatformStanding then
10 print("The player is PlatformStanding")
11 else
12 print("The player is not PlatformStanding")
13 end
14end
15
16humanoid.PlatformStanding:Connect(onPlatformStanding)

Ragdoll

This event fires when the Humanoid enters or leaves the Ragdoll HumanoidStateType.

The active parameter will have the value true or false to indicate entering or leaving.

Use Humanoid:SetStateEnabled() to disable the GettingUp state to stay in the Ragdoll state.

See also:

Parameters

active: boolean

Whether the Humanoid is entering or leaving the Ragdoll HumanoidStateType.


Code Samples

Humanoid action events

1local character = script.Parent
2
3local humanoid = character:WaitForChild("Humanoid")
4
5humanoid.Climbing:Connect(function(speed)
6 print("Climbing speed: ", speed)
7end)
8
9humanoid.FallingDown:Connect(function(isActive)
10 print("Falling down: ", isActive)
11end)
12
13humanoid.GettingUp:Connect(function(isActive)
14 print("Getting up: ", isActive)
15end)
16
17humanoid.Jumping:Connect(function(isActive)
18 print("Jumping: ", isActive)
19end)
20
21humanoid.PlatformStanding:Connect(function(isActive)
22 print("PlatformStanding: ", isActive)
23end)
24
25humanoid.Ragdoll:Connect(function(isActive)
26 print("Ragdoll: ", isActive)
27end)
28
29humanoid.Running:Connect(function(speed)
30 print("Running speed: ", speed)
31end)
32
33humanoid.Strafing:Connect(function(isActive)
34 print("Strafing: ", isActive)
35end)
36
37humanoid.Swimming:Connect(function(speed)
38 print("Swimming speed: ", speed)
39end)

Running

This event fires when the speed at which a Humanoid is running changes.

While running Humanoids cover, on average, their Humanoid.WalkSpeed in studs per second.

When the Humanoid stops running this event will fire with a speed of 0.

See also:

Parameters

speed: number

The speed at which the Humanoid is running.


Code Samples

Humanoid.Running

1local function onRunning(speed)
2 if speed > 0 then
3 print("Player is running")
4 else
5 print("Player has stopped")
6 end
7end
8
9workspace.Player.Humanoid.Running:Connect(onRunning)
Humanoid action events

1local character = script.Parent
2
3local humanoid = character:WaitForChild("Humanoid")
4
5humanoid.Climbing:Connect(function(speed)
6 print("Climbing speed: ", speed)
7end)
8
9humanoid.FallingDown:Connect(function(isActive)
10 print("Falling down: ", isActive)
11end)
12
13humanoid.GettingUp:Connect(function(isActive)
14 print("Getting up: ", isActive)
15end)
16
17humanoid.Jumping:Connect(function(isActive)
18 print("Jumping: ", isActive)
19end)
20
21humanoid.PlatformStanding:Connect(function(isActive)
22 print("PlatformStanding: ", isActive)
23end)
24
25humanoid.Ragdoll:Connect(function(isActive)
26 print("Ragdoll: ", isActive)
27end)
28
29humanoid.Running:Connect(function(speed)
30 print("Running speed: ", speed)
31end)
32
33humanoid.Strafing:Connect(function(isActive)
34 print("Strafing: ", isActive)
35end)
36
37humanoid.Swimming:Connect(function(speed)
38 print("Swimming speed: ", speed)
39end)

Seated

This event fires when a Humanoid either sits in or gets up from a Seat or VehicleSeat.

When a character comes into contact with a seat, they are attached to the seat and a sitting animation plays. For more information on this, see the Seat page.

  • If the character is sitting down, the active parameter will be true and currentSeatPart will be the seat they are currently sitting in.
  • If the character got up from a seat, the active parameter will be false and currentSeatPart will be nil.

See also:

  • Humanoid.Sit, which indicates if a Humanoid is currently sitting
  • Humanoid.SeatPart, which indicates the seat a Humanoid is currently sitting in, if any.

Parameters

active: boolean

True if the Humanoid is sitting down.

currentSeatPart: BasePart

The seat the Humanoid is sat in if it is sitting down.


Code Samples

Finding a Player's Seat

1local character = script.Parent
2local humanoid = character:WaitForChild("Humanoid")
3
4local function onSeated(isSeated, seat)
5 if isSeated then
6 print("I'm now sitting on: " .. seat.Name .. "!")
7 else
8 print("I'm not sitting on anything")
9 end
10end
11
12humanoid.Seated:Connect(onSeated)

StateChanged

This event fires when the state of the Humanoid is changed.

The humanoid state describes the activity the Humanoid is currently doing. It takes the form of a HumanoidStateType value.

See also:

Parameters

The Humanoid's previous state type.

The Humanoid's current state type.


Code Samples

Jump Cooldown

1local character = script.Parent
2
3local JUMP_DEBOUNCE = 1
4
5local humanoid = character:WaitForChild("Humanoid")
6
7local isJumping = false
8humanoid.StateChanged:Connect(function(_oldState, newState)
9 if newState == Enum.HumanoidStateType.Jumping then
10 if not isJumping then
11 isJumping = true
12 humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
13 end
14 elseif newState == Enum.HumanoidStateType.Landed then
15 if isJumping then
16 isJumping = false
17 task.wait(JUMP_DEBOUNCE)
18 humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
19 end
20 end
21end)
Jumping Particles

1local character = script.Parent
2
3local primaryPart = character.PrimaryPart
4
5-- create particles
6local particles = Instance.new("ParticleEmitter")
7particles.Size = NumberSequence.new(1)
8particles.Transparency = NumberSequence.new(0, 1)
9particles.Acceleration = Vector3.new(0, -10, 0)
10particles.Lifetime = NumberRange.new(1)
11particles.Rate = 20
12particles.EmissionDirection = Enum.NormalId.Back
13particles.Enabled = false
14particles.Parent = primaryPart
15
16local humanoid = character:WaitForChild("Humanoid")
17
18local isJumping = false
19
20-- listen to humanoid state
21local function onStateChanged(_oldState, newState)
22 if newState == Enum.HumanoidStateType.Jumping then
23 if not isJumping then
24 isJumping = true
25 particles.Enabled = true
26 end
27 elseif newState == Enum.HumanoidStateType.Landed then
28 if isJumping then
29 isJumping = false
30 particles.Enabled = false
31 end
32 end
33end
34
35humanoid.StateChanged:Connect(onStateChanged)

StateEnabledChanged

The StateEnableChanged event fires when Humanoid:SetStateEnabled() is called on the Humanoid.

Parameters include the HumanoidStateType in question along with a bool indicating if this state is now enabled.

See also:

Parameters

The HumanoidStateType for which the enabled state has been changed.

isEnabled: boolean

True if the state is now enabled.


Code Samples

Humanoid State Change Detector

1local Players = game:GetService("Players")
2
3local player = Players.LocalPlayer
4local character = player.Character or player.CharacterAdded:Wait()
5local humanoid = character:WaitForChild("Humanoid")
6
7local function onStateEnabledChanged(state, enabled)
8 if enabled then
9 print(state.Name .. " has been enabled")
10 else
11 print(state.Name .. " has been disabled")
12 end
13end
14
15humanoid.StateEnabledChanged:Connect(onStateEnabledChanged)

Strafing

This event does not fire when the Humanoid is strafing and should not be used by developers

This event is fired when the Humanoid enters or leaves the StrafingNoPhysics HumanoidStateType.

When the Humanoid enters the StrafingNoPhysics state this event will fire with an active parameter of true. The event will fire again with active equal to false when the Humanoid leaves the StrafingNoPhysics state.

This event is associated with the StrafingNoPhysics Humanoid state and does not fire when the Humanoid is moving perpendicular to the direction it is facing. This state is currently unused, if it is set using Humanoid:ChangeState() the state will revert to RunningNoPhysics.

Parameters

active: boolean

Whether the Humanoid is entering or leaving the StrafingNoPhysics HumanoidStateType.


Code Samples

Humanoid action events

1local character = script.Parent
2
3local humanoid = character:WaitForChild("Humanoid")
4
5humanoid.Climbing:Connect(function(speed)
6 print("Climbing speed: ", speed)
7end)
8
9humanoid.FallingDown:Connect(function(isActive)
10 print("Falling down: ", isActive)
11end)
12
13humanoid.GettingUp:Connect(function(isActive)
14 print("Getting up: ", isActive)
15end)
16
17humanoid.Jumping:Connect(function(isActive)
18 print("Jumping: ", isActive)
19end)
20
21humanoid.PlatformStanding:Connect(function(isActive)
22 print("PlatformStanding: ", isActive)
23end)
24
25humanoid.Ragdoll:Connect(function(isActive)
26 print("Ragdoll: ", isActive)
27end)
28
29humanoid.Running:Connect(function(speed)
30 print("Running speed: ", speed)
31end)
32
33humanoid.Strafing:Connect(function(isActive)
34 print("Strafing: ", isActive)
35end)
36
37humanoid.Swimming:Connect(function(speed)
38 print("Swimming speed: ", speed)
39end)

Swimming

This event fires when the speed at which a Humanoid is swimming in Terrain water changes.

Humanoids swim at 87.5% of their Humanoid.WalkSpeed.

This event will not always fire with a speed of 0 when the Humanoid stops swimming.

See also:

Parameters

speed: number

The speed the Humanoid is currently swimming at.


Code Samples

Humanoid action events

1local character = script.Parent
2
3local humanoid = character:WaitForChild("Humanoid")
4
5humanoid.Climbing:Connect(function(speed)
6 print("Climbing speed: ", speed)
7end)
8
9humanoid.FallingDown:Connect(function(isActive)
10 print("Falling down: ", isActive)
11end)
12
13humanoid.GettingUp:Connect(function(isActive)
14 print("Getting up: ", isActive)
15end)
16
17humanoid.Jumping:Connect(function(isActive)
18 print("Jumping: ", isActive)
19end)
20
21humanoid.PlatformStanding:Connect(function(isActive)
22 print("PlatformStanding: ", isActive)
23end)
24
25humanoid.Ragdoll:Connect(function(isActive)
26 print("Ragdoll: ", isActive)
27end)
28
29humanoid.Running:Connect(function(speed)
30 print("Running speed: ", speed)
31end)
32
33humanoid.Strafing:Connect(function(isActive)
34 print("Strafing: ", isActive)
35end)
36
37humanoid.Swimming:Connect(function(speed)
38 print("Swimming speed: ", speed)
39end)

Touched

This event fires when one of the Humanoid's limbs come in contact with another BasePart.

The BasePart the Humanoid's limb is touching along with the limb itself is given.

This event will not fire when limbs belonging to the Humanoid come into contact with themselves.

Alternatives to the Humanoid Touched event

Although the Humanoid.Touched event is useful, developers should consider if there are alternatives that suit their needs better before using it.

  • In most cases it is advised to connect a BasePart.Touched event for BaseParts of interest instead. This is because the Humanoid Touched event will constantly fire when the humanoid is moving. For example, in a dodgeball game it would be more practical to connect a touched event for the balls rather than the humanoid
  • For developers trying to work out when the Humanoid has landed on the ground, the Humanoid.StateChanged event is more suitable. Alternatively, developers can use Humanoid.FloorMaterial to see if the Humanoid is standing on anything

Note:

Parameters

touchingPart: BasePart

The BasePart the Humanoid has come in contact with.

humanoidPart: BasePart

The limb of the Humanoid that has been touched.


Code Samples

Midas Touch

1local character = script.Parent
2
3local humanoid = character:WaitForChild("Humanoid")
4
5local partInfo = {}
6
7local debounce = false
8
9local function onHumanoidTouched(hit, _limb)
10 if debounce then
11 return
12 end
13
14 if not hit.CanCollide or hit.Transparency ~= 0 then
15 return
16 end
17
18 if not partInfo[hit] then
19 partInfo[hit] = {
20 BrickColor = hit.BrickColor,
21 Material = hit.Material,
22 }
23
24 hit.BrickColor = BrickColor.new("Gold")
25 hit.Material = Enum.Material.Ice
26
27 debounce = true
28 task.wait(0.2)
29 debounce = false
30 end
31end
32
33local touchedConnection = humanoid.Touched:Connect(onHumanoidTouched)
34
35local function onHumanoidDied()
36 if touchedConnection then
37 touchedConnection:Disconnect()
38 end
39
40 -- undo all of the gold
41 for part, info in pairs(partInfo) do
42 if part and part.Parent then
43 part.BrickColor = info.BrickColor
44 part.Material = info.Material
45 end
46 end
47end
48
49humanoid.Died:Connect(onHumanoidDied)

Methods

AddAccessory

void

The AddAccessory function attaches the specified Accessory to the Humanoid's parent.

How are Accessories attached to Humanoids?

When this function is called, the Accessory is parented to the Humanoid's parent and then attached.

An Accessory is attached to the character by searching for an Attachment in the Humanoid's parent that shares the same name as an Attachment in the accessory's Handle Part. If one is found, the Handle part will be connected to the parent of the Attachment using a Weld. This weld will be configured so the Attachments occupy the same space.

If the required Attachment can not be found, then the Accessory will remain parented to the Humanoid's parent but it will be unattached.

Parameters

accessory: Instance

The Accessory to be attached.


Returns

void

No return.

Code Samples

[Humanoid] AddAccessory Example

1local playerModel = script.Parent
2local humanoid = playerModel:WaitForChild("Humanoid")
3
4local clockworksShades = Instance.new("Accessory")
5clockworksShades.Name = "ClockworksShades"
6
7local handle = Instance.new("Part")
8handle.Name = "Handle"
9handle.Size = Vector3.new(1, 1.6, 1)
10handle.Parent = clockworksShades
11
12local faceFrontAttachment = Instance.new("Attachment")
13faceFrontAttachment.Name = "FaceFrontAttachment"
14faceFrontAttachment.Position = Vector3.new(0, -0.24, -0.45)
15faceFrontAttachment.Parent = handle
16
17local mesh = Instance.new("SpecialMesh")
18mesh.Name = "Mesh"
19mesh.Scale = Vector3.new(1, 1.3, 1)
20mesh.MeshId = "rbxassetid://1577360"
21mesh.TextureId = "rbxassetid://1577349"
22mesh.Parent = handle
23
24humanoid:AddAccessory(clockworksShades)

ApplyDescriptionBlocking

void
Roblox Script Security

Parameters

humanoidDescription: HumanoidDescription

Returns

void

BuildRigFromAttachments

void

BuildRigFromAttachments assembles a tree of Motor6D joints for a Humanoid. Motor6D joints are required for the playback of Animations

Starting from the humanoid's Humanoid.RootPart, the function collects all Attachments parented in the current part, whose name ends with "RigAttachment". It then searches for a matching attachment in the character that shares the same name as the attachment. Using those two attachments, a Motor6D joint is generated based on the parts associated with the two attachments, and the Attachment.CFrames of the attachments.

BuildRigFromAttachments also scales the character and sets body colors.

See the provided code sample below to see how this function works.


Returns

void

Code Samples

Lua Port of BuildRigFromAttachments

1local function createJoint(jointName, att0, att1)
2 local part0, part1 = att0.Parent, att1.Parent
3 local newMotor = part1:FindFirstChild(jointName)
4
5 if not (newMotor and newMotor:IsA("Motor6D")) then
6 newMotor = Instance.new("Motor6D")
7 end
8
9 newMotor.Name = jointName
10
11 newMotor.Part0 = part0
12 newMotor.Part1 = part1
13
14 newMotor.C0 = att0.CFrame
15 newMotor.C1 = att1.CFrame
16
17 newMotor.Parent = part1
18end
19
20local function buildJointsFromAttachments(part, characterParts)
21 if not part then
22 return
23 end
24
25 -- first, loop thru all of the part's children to find attachments
26 for _, attachment in pairs(part:GetChildren()) do
27 if attachment:IsA("Attachment") then
28 -- only do joint build from "RigAttachments"
29 local attachmentName = attachment.Name
30 local findPos = attachmentName:find("RigAttachment")
31 if findPos then
32 -- also don't make double joints (there is the same named
33 -- rigattachment under two parts)
34 local jointName = attachmentName:sub(1, findPos - 1)
35 if not part:FindFirstChild(jointName) then
36 -- try to find other part with same rig attachment name
37 for _, characterPart in pairs(characterParts) do
38 if part ~= characterPart then
39 local matchingAttachment = characterPart:FindFirstChild(attachmentName)
40 if matchingAttachment and matchingAttachment:IsA("Attachment") then
41 createJoint(jointName, attachment, matchingAttachment)
42 buildJointsFromAttachments(characterPart, characterParts)
43 break
44 end
45 end
46 end
47 end
48 end
49 end
50 end
51end
52
53local function buildRigFromAttachments(humanoid)
54 local rootPart = humanoid.RootPart
55 assert(rootPart, "Humanoid has no HumanoidRootPart.")
56
57 local characterParts = {}
58
59 for _, descendant in ipairs(humanoid.Parent:GetDescendants()) do
60 if descendant:IsA("BasePart") then
61 table.insert(characterParts, descendant)
62 end
63 end
64
65 buildJointsFromAttachments(rootPart, characterParts)
66end
67
68local humanoid = script.Parent:WaitForChild("Humanoid")
69
70buildRigFromAttachments(humanoid)
R15 Package Importer

1local AssetService = game:GetService("AssetService")
2local InsertService = game:GetService("InsertService")
3local MarketplaceService = game:GetService("MarketplaceService")
4
5local PACKAGE_ASSET_ID = 193700907 -- Circuit Breaker
6
7local function addAttachment(part, name, position, orientation)
8 local attachment = Instance.new("Attachment")
9 attachment.Name = name
10 attachment.Parent = part
11 if position then
12 attachment.Position = position
13 end
14 if orientation then
15 attachment.Orientation = orientation
16 end
17 return attachment
18end
19
20local function createBaseCharacter()
21 local character = Instance.new("Model")
22
23 local humanoid = Instance.new("Humanoid")
24 humanoid.Parent = character
25
26 local rootPart = Instance.new("Part")
27 rootPart.Name = "HumanoidRootPart"
28 rootPart.Size = Vector3.new(2, 2, 1)
29 rootPart.Transparency = 1
30 rootPart.Parent = character
31 addAttachment(rootPart, "RootRigAttachment")
32
33 local head = Instance.new("Part")
34 head.Name = "Head"
35 head.Size = Vector3.new(2, 1, 1)
36 head.Parent = character
37
38 local headMesh = Instance.new("SpecialMesh")
39 headMesh.Scale = Vector3.new(1.25, 1.25, 1.25)
40 headMesh.MeshType = Enum.MeshType.Head
41 headMesh.Parent = head
42
43 local face = Instance.new("Decal")
44 face.Name = "face"
45 face.Texture = "rbxasset://textures/face.png"
46 face.Parent = head
47
48 addAttachment(head, "FaceCenterAttachment")
49 addAttachment(head, "FaceFrontAttachment", Vector3.new(0, 0, -0.6))
50 addAttachment(head, "HairAttachment", Vector3.new(0, 0.6, 0))
51 addAttachment(head, "HatAttachment", Vector3.new(0, 0.6, 0))
52 addAttachment(head, "NeckRigAttachment", Vector3.new(0, -0.5, 0))
53
54 return character, humanoid
55end
56
57local function createR15Package(packageAssetId)
58 local packageAssetInfo = MarketplaceService:GetProductInfo(packageAssetId)
59
60 local character, humanoid = createBaseCharacter()
61 character.Name = packageAssetInfo.Name
62
63 local assetIds = AssetService:GetAssetIdsForPackage(packageAssetId)
64 for _, assetId in pairs(assetIds) do
65 local limb = InsertService:LoadAsset(assetId)
66 local r15 = limb:FindFirstChild("R15")
67 if r15 then
68 for _, part in pairs(r15:GetChildren()) do
69 part.Parent = character
70 end
71 else
72 for _, child in pairs(limb:GetChildren()) do
73 child.Parent = character
74 end
75 end
76 end
77
78 humanoid:BuildRigFromAttachments()
79 return character
80end
81
82local r15Package = createR15Package(PACKAGE_ASSET_ID)
83r15Package.Parent = workspace

CacheDefaults

void
Roblox Script Security

Returns

void

ChangeState

void

This function causes the Humanoid to enter the given HumanoidStateType.

The humanoid state describes the activity the Humanoid is currently doing.

You should check the page for HumanoidStateType for more information on what particular states do as some have unintuitive names. For example, running describes a state where the Humanoid's legs are on the ground, including when stationary

Due to the default behavior of the Humanoid some states will automatically be changed when set to. For example:

  • Setting the state to 'Swimming' when the Humanoid is not in the water will lead to it being automatically set to 'GettingUp'
  • As it is unused, setting the state to 'PlatformStanding' will lead to it being automatically set to 'Running'

See also:

Parameters

The HumanoidStateType that the Humanoid is to perform.

Default Value: "None"

Returns

void

No return.

Code Samples

Double Jump

1local UserInputService = game:GetService("UserInputService")
2local character = script.Parent
3
4local humanoid = character:WaitForChild("Humanoid")
5
6local doubleJumpEnabled = false
7
8humanoid.StateChanged:Connect(function(_oldState, newState)
9 if newState == Enum.HumanoidStateType.Jumping then
10 if not doubleJumpEnabled then
11 task.wait(0.2)
12 if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
13 doubleJumpEnabled = true
14 end
15 end
16 elseif newState == Enum.HumanoidStateType.Landed then
17 doubleJumpEnabled = false
18 end
19end)
20
21UserInputService.InputBegan:Connect(function(inputObject)
22 if inputObject.KeyCode == Enum.KeyCode.Space then
23 if doubleJumpEnabled then
24 if humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then
25 humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
26 task.spawn(function()
27 doubleJumpEnabled = false
28 end)
29 end
30 end
31 end
32end)

EquipTool

void

This function makes the Humanoid equip the given Tool.

The below example would cause a Player to equip a tool in Workspace named 'Tool'.


1local Players = game:GetService("Players")
2
3local player = Players:FindFirstChildOfClass("Player")
4if player and player.Character then
5 local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
6 if humanoid then
7 local tool = workspace:FindFirstChild("Tool")
8 if tool then
9 humanoid:EquipTool(tool)
10 end
11 end
12end
13

When this function is called, the humanoid will automatically unequip any Tools that it currently has equipped

Although they will be equipped, Tools for which Tool.RequiresHandle is true will not function if they have no handle, regardless if this function is used to equip them or not

See also:

Parameters

tool: Instance

The Tool to equip.


Returns

void

No return.

Code Samples