Humanoidクラス

クラス日本語解説あり

ひとことで言うと

キャラクターの「体の動き」と「体力」を管理するクラスです。歩く速さ・ジャンプ・体力・やられたときのイベントなどを扱います。

公式の説明(英語):A special object that gives models the functionality of a character.

使用例

ふれたプレイヤーを倒すブロック(キルブロック)
Script置く場所:パーツの中
local part = script.Parent :: BasePart

part.Touched:Connect(function(hit)
	local character = hit.Parent
	if not character then
		return
	end
	local humanoid = character:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end)
参加したプレイヤーの歩く速さを変える
Script置く場所:ServerScriptService
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid") :: Humanoid
		humanoid.WalkSpeed = 32
	end)
end)

スクリプトは、Luauの型チェック(luau-lsp)で確認しています。

クラスの関係

受け継いでいるクラス:Object → Instance → Humanoid

プロパティ(32)

名前と書き方説明
AutoJumpEnabled
Humanoid.AutoJumpEnabled: boolean
Sets whether the character will automatically jump when they hit an obstacle as a player on a mobile device.
AutomaticScalingEnabled
Humanoid.AutomaticScalingEnabled: boolean
When Enabled, AutomaticScalingEnabled causes the size of the character to change in response to the values in the humanoid's child scale values changing.
AutoRotate
Humanoid.AutoRotate: boolean
AutoRotate sets whether or not the Humanoid will automatically rotate to face in the direction they are moving in.
BreakJointsOnDeath
Humanoid.BreakJointsOnDeath: boolean
Determines whether the humanoid's joints break when in the HumanoidStateType.Dead state.
CameraOffset
Humanoid.CameraOffset: Vector3
An offset applied to the Camera's subject position when its CameraSubject is set to this Humanoid.
DisplayDistanceType
Humanoid.DisplayDistanceType: HumanoidDisplayDistanceType
Controls the distance behavior of the humanoid's name and health display.
DisplayName
Humanoid.DisplayName: string
Sets the text of a Humanoid, displayed above their head.
EvaluateStateMachine
Humanoid.EvaluateStateMachine: boolean
Used to disable the internal physics and state machine of the Humanoid.
FloorMaterial
Humanoid.FloorMaterial: Material
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_.
Health
Humanoid.Health: float
今の体力。0になると、キャラクターがやられます。Describes the current health of the Humanoid on the range [0, Humanoid.MaxHealth].
HealthDisplayDistance
Humanoid.HealthDisplayDistance: float
Used in conjunction with the Class.Humanoid.DisplayDistanceType|DisplayDistanceType property to control the distance from which a humanoid's health bar can be seen.
HealthDisplayType
Humanoid.HealthDisplayType: HumanoidHealthDisplayType
Controls when the humanoid's health bar is allowed to be displayed.
HipHeight
Humanoid.HipHeight: float
Determines the distance off the ground the Humanoid.RootPart should be.
Jump
Humanoid.Jump: boolean
If true, the Humanoid jumps with an upwards force.
JumpHeight
Humanoid.JumpHeight: float
ジャンプの高さ(UseJumpPowerがfalseのとき)。Provides control over the height that the Humanoid jumps to.
JumpPower
Humanoid.JumpPower: float
ジャンプの強さ(UseJumpPowerがtrueのとき)。Determines how much upwards force is applied to the Humanoid when jumping.
MaxHealth
Humanoid.MaxHealth: float
体力の最大値。初期値は100です。The maximum value of a humanoid's Class.Humanoid.Health|Health.
MaxSlopeAngle
Humanoid.MaxSlopeAngle: float
The maximum slope angle that a humanoid can walk on without slipping.
MoveDirection
Humanoid.MoveDirection: Vector3
Describes the direction that the Humanoid is walking in.
NameDisplayDistance
Humanoid.NameDisplayDistance: float
Used in conjunction with the Humanoid.DisplayDistanceType property to control the distance from which a humanoid's name can be seen.
NameOcclusion
Humanoid.NameOcclusion: NameOcclusion
Controls whether a humanoid's name and health bar can be seen behind walls or other objects.
PlatformStand
Humanoid.PlatformStand: boolean
Determines whether the Humanoid is currently in the HumanoidStateType.PlatformStanding state.
RequiresNeck
Humanoid.RequiresNeck: boolean
Allows developers to disable the behavior where a player Character|character dies if the Neck Motor6D is removed or disconnected even momentarily.
RigType
Humanoid.RigType: HumanoidRigType
Describes whether this Humanoid is utilizing the legacy R6 character rig, or the new R15 character rig.
RootPart
Humanoid.RootPart: BasePart
A reference to the humanoid's HumanoidRootPart object.
SeatPart
Humanoid.SeatPart: BasePart
A reference to the seat that a Humanoid is currently sitting in, if any.
Sit
Humanoid.Sit: boolean
Describes whether the Humanoid is currently sitting.
TargetPoint
Humanoid.TargetPoint: Vector3
Describes the 3D position where the Player controlling the Humanoid last clicked in the world while using a Tool.
UseJumpPower
Humanoid.UseJumpPower: boolean
Determines whether the Class.Humanoid.JumpHeight|JumpHeight (false) or Humanoid.JumpPower (true) property is used.
WalkSpeed
Humanoid.WalkSpeed: float
歩く速さ。初期値は16です。Describes the humanoid's maximum movement speed in studs per second.
WalkToPart
Humanoid.WalkToPart: BasePart
A reference to a part whose position is trying to be reached by a humanoid.
WalkToPoint
Humanoid.WalkToPoint: Vector3
The position that a humanoid is trying to reach, after a call to Class.Humanoid:MoveTo() is made.

メソッド(22)

名前と書き方説明
AddAccessory
Humanoid:AddAccessory(accessory: Instance): ()
Attaches the specified Accessory to the humanoid's parent.
ApplyDescriptionAsync
Humanoid:ApplyDescriptionAsync(humanoidDescription: HumanoidDescription, assetTypeVerification: AssetTypeVerification): ()
Makes the character's look match that of the passed in HumanoidDescription. If HumanoidDescription.UseAvatarSettings is true, the Avatar Settings for the experience will also be applied to the character.
ApplyDescriptionResetAsync
Humanoid:ApplyDescriptionResetAsync(humanoidDescription: HumanoidDescription, assetTypeVerification: AssetTypeVerification): ()
Makes the character's look match that of the passed in HumanoidDescription, even after external changes.
BuildRigFromAttachments
Humanoid:BuildRigFromAttachments(): ()
Assembles a tree of Motor6D joints by attaching together Attachment objects in a humanoid's character.
ChangeState
Humanoid:ChangeState(state: HumanoidStateType): ()
Sets the Humanoid to enter the given HumanoidStateType.
EquipTool
Humanoid:EquipTool(tool: Instance): ()
Makes the Humanoid equip the given Tool.
GetAccessories
Humanoid:GetAccessories(): Array
Returns an array of Accessory objects that the humanoid's parent is currently wearing.
GetAppliedDescription
Humanoid:GetAppliedDescription(): HumanoidDescription
Returns a copy of the humanoid's cached HumanoidDescription which describes its current look.
GetBodyPartR15
Humanoid:GetBodyPartR15(part: Instance): BodyPartR15
Pass a body part to this method (the body part should be a sibling of Humanoid, and a child of a Model) to get the BodyPartR15 of the Part.
GetLimb
Humanoid:GetLimb(part: Instance): Limb
Returns the Limb enum that is associated with the given Part.
GetMoveVelocity
Humanoid:GetMoveVelocity(): Vector3
Returns the current intended movement velocity of the Humanoid.
GetRelativeVelocityAtFloor
Humanoid:GetRelativeVelocityAtFloor(): Vector3
Returns the humanoid's actual physical velocity relative to the surface it is standing on as a Vector3 in world-space orientation.
GetState
Humanoid:GetState(): HumanoidStateType
Returns the humanoid's current HumanoidStateType.
GetStateEnabled
Humanoid:GetStateEnabled(state: HumanoidStateType): boolean
Returns whether a HumanoidStateType is enabled for the Humanoid.
Move
Humanoid:Move(moveDirection: Vector3, relativeToCamera: boolean): ()
Causes the Humanoid to walk in the given direction.
MoveTo
Humanoid:MoveTo(location: Vector3, part: Instance): ()
指定した場所へ歩いて移動させます。Causes the Humanoid to attempt to walk to the given location by setting the Humanoid.WalkToPoint and Humanoid.WalkToPart properties.
PlayEmoteAsync
Humanoid:PlayEmoteAsync(emoteName: string): boolean
Plays emotes and returns if was successfully ran.
RemoveAccessories
Humanoid:RemoveAccessories(): ()
Removes all Accessory objects worn by the humanoid's parent.
ReplaceBodyPartR15
Humanoid:ReplaceBodyPartR15(bodyPart: BodyPartR15, part: BasePart): boolean
Dynamically replaces a Humanoid body part with a different part.
SetStateEnabled
Humanoid:SetStateEnabled(state: HumanoidStateType, enabled: boolean): ()
Sets whether a given HumanoidStateType is enabled for the Humanoid.
TakeDamage
Humanoid:TakeDamage(amount: float): ()
体力を減らします(バリアなどで守られているときは減りません)。Lowers the Humanoid.Health of the Humanoid by the given _amount_ if it is not protected by a ForceField.
UnequipTools
Humanoid:UnequipTools(): ()
Unequips any Tool currently equipped by the Humanoid.

イベント(18)

名前と書き方説明
ApplyDescriptionFinished
Humanoid.ApplyDescriptionFinished(description: HumanoidDescription)
Fires when a HumanoidDescription has finished being applied to the Humanoid.
Climbing
Humanoid.Climbing(speed: float)
Fires when the speed at which a Humanoid is climbing changes.
Died
Humanoid.Died()
キャラクターがやられたときに発生するイベントです。Fires when the Humanoid dies.
FallingDown
Humanoid.FallingDown(active: boolean)
Fires when the Humanoid enters or leaves the FallingDown HumanoidStateType.
FreeFalling
Humanoid.FreeFalling(active: boolean)
Fires when the Humanoid enters or leaves the Freefall HumanoidStateType.
GettingUp
Humanoid.GettingUp(active: boolean)
Fires when the Humanoid enters or leaves the GettingUp HumanoidStateType.
HealthChanged
Humanoid.HealthChanged(health: float)
体力が変わったときに発生するイベントです。Fires when the Humanoid.Health changes (or when the Humanoid.MaxHealth is set).
Jumping
Humanoid.Jumping(active: boolean)
Fires when the Humanoid enters and leaves the Jumping HumanoidStateType.
MoveToFinished
Humanoid.MoveToFinished(reached: boolean)
Fires when the Humanoid finishes walking to a goal declared by Class.Humanoid:MoveTo().
PlatformStanding
Humanoid.PlatformStanding(active: boolean)
Fires when the Humanoid enters or leaves the PlatformStanding HumanoidStateType.
Ragdoll
Humanoid.Ragdoll(active: boolean)
Fires when the Humanoid enters or leaves the Ragdoll HumanoidStateType.
Running
Humanoid.Running(speed: float)
Fires when the speed at which a Humanoid is running changes.
Seated
Humanoid.Seated(active: boolean, currentSeatPart: BasePart)
Fired when a Humanoid either sits in a Seat or VehicleSeat or gets up.
StateChanged
Humanoid.StateChanged(old: HumanoidStateType, new: HumanoidStateType)
Fires when the state of the Humanoid is changed.
StateEnabledChanged
Humanoid.StateEnabledChanged(state: HumanoidStateType, isEnabled: boolean)
Fires when Class.Humanoid:SetStateEnabled() is called on the Humanoid.
Strafing
Humanoid.Strafing(active: boolean)
Fires when the Humanoid enters or leaves the StrafingNoPhysics HumanoidStateType.
Swimming
Humanoid.Swimming(speed: float)
Fires when the speed at which a Humanoid is swimming in Terrain water changes.
Touched
Humanoid.Touched(touchingPart: BasePart, humanoidPart: BasePart)
Fires when one of the humanoid's limbs come in contact with another BasePart.

受け継いでいるメンバー

Instance から受け継いでいるもの(46)

Archivable・Capabilities・IsInSandbox・Name・Parent・PredictionMode・Sandboxed・AddTag・ClearAllChildren・Clone・Destroy・FindFirstAncestor・FindFirstAncestorOfClass・FindFirstAncestorWhichIsA・FindFirstChild・FindFirstChildOfClass・FindFirstChildWhichIsA・FindFirstDescendant・GetActor・GetAttribute・GetAttributeChangedSignal・GetAttributes・GetChildren・GetDebugId・GetDescendants・GetFullName・GetStyled・GetStyledPropertyChangedSignal・GetTags・HasTag・IsAncestorOf・IsDescendantOf・IsPropertyModified・QueryDescendants・RemoveTag・ResetPropertyToDefault・SetAttribute・WaitForChild・AncestryChanged・AttributeChanged・ChildAdded・ChildRemoved・DescendantAdded・DescendantRemoving・Destroying・StyledPropertiesChanged

Object から受け継いでいるもの(4)

ClassName・GetPropertyChangedSignal・IsA・Changed

Humanoidを使う記事

英語の説明とメンバーの一覧は、Roblox Creator Documentation(Humanoid)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。

執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。沖縄マイクラ部 クロスウェーブで、ロブロックス(Roblox)・マインクラフト(マイクラ)・Scratchなどのプログラミングを指導。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにロブロックス(Roblox)やマインクラフト(マイクラ)のプログラミングを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む