Apprendre
Classe de moteur
Humanoid

*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.


Résumé
Méthodes
AddAccessory(accessory: Instance):()
AddCustomStatus(status: string):boolean
Déprécié
AddStatus(status: Enum.Status):boolean
Déprécié
ApplyDescription(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
Déprécié
ApplyDescriptionAsync(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
ApplyDescriptionReset(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
Déprécié
ApplyDescriptionResetAsync(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
GetStatuses():{any}
Déprécié
HasCustomStatus(status: string):boolean
Déprécié
HasStatus(status: Enum.Status):boolean
Déprécié
LoadAnimation(animation: Animation):AnimationTrack
Déprécié
loadAnimation(animation: Animation):AnimationTrack
Déprécié
Move(moveDirection: Vector3,relativeToCamera: boolean):()
MoveTo(location: Vector3,part: Instance):()
PlayEmote(emoteName: string):boolean
Déprécié
RemoveCustomStatus(status: string):boolean
Déprécié
RemoveStatus(status: Enum.Status):boolean
Déprécié
TakeDamage(amount: number):()
takeDamage(amount: number):()
Déprécié
Membres hérités
Échantillons de code
Effet de balancement de caméra en marchant
local RunService = game:GetService("RunService")
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local function updateBobbleEffect()
local now = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- Le personnage est-il en marche ?
local velocity = humanoid.RootPart.Velocity
local bobble_X = math.cos(now * 9) / 5
local bobble_Y = math.abs(math.sin(now * 12)) / 5
local bobble = Vector3.new(bobble_X, bobble_Y, 0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, 0.25)
else
-- Réduire le CameraOffset afin qu'il retourne à sa position normale.
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)

Référence API
Propriétés
AutoJumpEnabled
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.AutoJumpEnabled:boolean
Échantillons de code
Bascule d'auto-saut
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local button = script.Parent
local function update()
-- Mettre à jour le texte du bouton
if player.AutoJumpEnabled then
button.Text = "L'auto-saut est ACTIVÉ"
else
button.Text = "L'auto-saut est DÉSACTIVÉ"
end
-- Refléter la propriété dans le personnage du joueur, s'il en a un
if player.Character then
local human = player.Character:FindFirstChild("Humanoid")
if human then
human.AutoJumpEnabled = player.AutoJumpEnabled
end
end
end
local function onActivated()
-- Basculer l'auto-saut
player.AutoJumpEnabled = not player.AutoJumpEnabled
-- Mettre à jour tout le reste
update()
end
button.Activated:Connect(onActivated)
update()

AutomaticScalingEnabled
Lecture parallèle
Capacités : AvatarAppearance
Humanoid.AutomaticScalingEnabled:boolean

AutoRotate
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.AutoRotate:boolean
Échantillons de code
Bouton d'AutoRotation
local button = script.Parent
local enabled = true
local ON_COLOR = BrickColor.Green()
local OFF_COLOR = BrickColor.Red()
local function touchButton(humanoid)
if enabled then
enabled = false
button.BrickColor = OFF_COLOR
if humanoid.AutoRotate then
print(humanoid:GetFullName() .. " ne peut plus faire de rotation automatique !")
humanoid.AutoRotate = false
else
print(humanoid:GetFullName() .. " peut maintenant faire de la rotation automatique !")
humanoid.AutoRotate = true
end
task.wait(1)
button.BrickColor = ON_COLOR
enabled = true
end
end
local function onTouched(hit)
local char = hit:FindFirstAncestorWhichIsA("Model")
if char then
local humanoid = char:FindFirstChildOfClass("Humanoid")
if humanoid then
touchButton(humanoid)
end
end
end
button.Touched:Connect(onTouched)
button.BrickColor = ON_COLOR

BreakJointsOnDeath
Lecture parallèle
Capacités : AvatarBehavior
Humanoid.BreakJointsOnDeath:boolean

CameraOffset
Lecture parallèle
Capacités : AvatarBehavior
Humanoid.CameraOffset:Vector3
Échantillons de code
Effet de balancement de caméra en marchant
local RunService = game:GetService("RunService")
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local function updateBobbleEffect()
local now = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- Le personnage est-il en marche ?
local velocity = humanoid.RootPart.Velocity
local bobble_X = math.cos(now * 9) / 5
local bobble_Y = math.abs(math.sin(now * 12)) / 5
local bobble = Vector3.new(bobble_X, bobble_Y, 0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, 0.25)
else
-- Réduire le CameraOffset afin qu'il retourne à sa position normale.
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)

CollisionType
Déprécié

DisplayDistanceType
Lecture parallèle
Capacités : AvatarAppearance
Humanoid.DisplayDistanceType:Enum.HumanoidDisplayDistanceType
Échantillons de code
Affichage de la santé et du nom d'un humanoïde
local humanoid = script.Parent
humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.Viewer
humanoid.HealthDisplayDistance = 0
humanoid.NameDisplayDistance = 100

DisplayName
Lecture parallèle
Capacités : AvatarAppearance
Humanoid.DisplayName:string

EvaluateStateMachine
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.EvaluateStateMachine:boolean

FloorMaterial
Lecture uniquement
Non répliqué
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.FloorMaterial:Enum.Material

Health
Non répliqué
Lecture parallèle
Capacités : AvatarBehavior
Humanoid.Health:number

HealthDisplayDistance
Lecture parallèle
Capacités : AvatarAppearance
Humanoid.HealthDisplayDistance:number

HealthDisplayType
Lecture parallèle
Capacités : AvatarAppearance
Humanoid.HealthDisplayType:Enum.HumanoidHealthDisplayType

HipHeight
Lecture parallèle
Capacités : AvatarAppearance
Accès à la simulation
Humanoid.HipHeight:number

Jump
Non répliqué
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.Jump:boolean

JumpHeight
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.JumpHeight:number

JumpPower
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.JumpPower:number

LeftLeg
Déprécié

MaxHealth
Lecture parallèle
Capacités : AvatarBehavior
Humanoid.MaxHealth:number

maxHealth
Déprécié

MaxSlopeAngle
Lecture parallèle
Capacités : AvatarBehavior
Humanoid.MaxSlopeAngle:number
Échantillons de code
Limiter la pente qu'un humanoïde peut gravir
local player = game.Players.LocalPlayer
local char = player.CharacterAdded:wait()
local h = char:FindFirstChild("Humanoid")
h.MaxSlopeAngle = 30

MoveDirection
Lecture uniquement
Non répliqué
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.MoveDirection:Vector3
Échantillons de code
Effet de balancement de caméra en marchant
local RunService = game:GetService("RunService")
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local function updateBobbleEffect()
local now = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- Le personnage est-il en marche ?
local velocity = humanoid.RootPart.Velocity
local bobble_X = math.cos(now * 9) / 5
local bobble_Y = math.abs(math.sin(now * 12)) / 5
local bobble = Vector3.new(bobble_X, bobble_Y, 0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, 0.25)
else
-- Réduire le CameraOffset afin qu'il retourne à sa position normale.
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)

NameDisplayDistance
Lecture parallèle
Capacités : AvatarAppearance
Humanoid.NameDisplayDistance:number

NameOcclusion
Lecture parallèle
Capacités : AvatarAppearance
Humanoid.NameOcclusion:Enum.NameOcclusion
Échantillons de code
Masquer les noms des joueurs
local Players = game:GetService("Players")
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.NamOcclusion = Enum.NameOcclusion.OccludeAll
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)

PlatformStand
Lecture parallèle
Capacités : AvatarBehavior
Humanoid.PlatformStand:boolean

RequiresNeck
Lecture parallèle
Capacités : AvatarBehavior
Humanoid.RequiresNeck:boolean

RightLeg
Déprécié

RigType
Lecture parallèle
Capacités : AvatarAppearance
Humanoid.RigType:Enum.HumanoidRigType

RootPart
Lecture uniquement
Non répliqué
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.RootPart:BasePart

SeatPart
Lecture uniquement
Non répliqué
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.SeatPart:BasePart

Sit
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.Sit:boolean

TargetPoint
Lecture parallèle
Capacités : AvatarBehavior
Humanoid.TargetPoint:Vector3

Torso
Déprécié

UseJumpPower
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.UseJumpPower:boolean

WalkSpeed
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.WalkSpeed:number

WalkToPart
Lecture parallèle
Capacités : AvatarBehavior
Humanoid.WalkToPart:BasePart

WalkToPoint
Lecture parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid.WalkToPoint:Vector3

Méthodes
AddAccessory
Capacités : AvatarAppearance
Humanoid:AddAccessory(accessory:Instance):()
Paramètres
accessory:Instance
Retours
()
Échantillons de code
[Humanoïde] Exemple d'Ajout d'Accessoire
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local clockworksShades = Instance.new("Accessory")
clockworksShades.Name = "ClockworksShades"
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Size = Vector3.new(1, 1.6, 1)
handle.Parent = clockworksShades
local faceFrontAttachment = Instance.new("Attachment")
faceFrontAttachment.Name = "FaceFrontAttachment"
faceFrontAttachment.Position = Vector3.new(0, -0.24, -0.45)
faceFrontAttachment.Parent = handle
local mesh = Instance.new("SpecialMesh")
mesh.Name = "Mesh"
mesh.Scale = Vector3.new(1, 1.3, 1)
mesh.MeshId = "rbxassetid://1577360"
mesh.TextureId = "rbxassetid://1577349"
mesh.Parent = handle
humanoid:AddAccessory(clockworksShades)

AddCustomStatus
Déprécié

AddStatus
Déprécié

ApplyDescription
Déprécié

ApplyDescriptionAsync
Rendement
Capacités : AvatarAppearance
Humanoid:ApplyDescriptionAsync(
humanoidDescription:HumanoidDescription, assetTypeVerification:Enum.AssetTypeVerification
):()
Paramètres
humanoidDescription:HumanoidDescription
assetTypeVerification:Enum.AssetTypeVerification
Valeur par défaut : "Default"
Retours
()

ApplyDescriptionReset
Déprécié

ApplyDescriptionResetAsync
Rendement
Capacités : AvatarAppearance
Humanoid:ApplyDescriptionResetAsync(
humanoidDescription:HumanoidDescription, assetTypeVerification:Enum.AssetTypeVerification
):()
Paramètres
humanoidDescription:HumanoidDescription
assetTypeVerification:Enum.AssetTypeVerification
Valeur par défaut : "Default"
Retours
()

BuildRigFromAttachments
Capacités : AvatarBehavior
Humanoid:BuildRigFromAttachments():()
Retours
()
Échantillons de code
Port Lua de BuildRigFromAttachments
local function createJoint(jointName, att0, att1)
local partForJoint = att1.Parent
while partForJoint and not partForJoint:IsA("BasePart") do
partForJoint = partForJoint.Parent
end
local oldJoint = partForJoint:FindFirstChild(jointName)
if oldJoint and oldJoint:IsA("AnimationConstraint") then
oldJoint.Attachment0 = att0
oldJoint.Attachment1 = att1
oldJoint.Parent = partForJoint
else
local ac = Instance.new("AnimationConstraint")
ac.Name = jointName
ac.IsKinematic = true
ac.Attachment0 = att0
ac.Attachment1 = att1
ac.Parent = partForJoint
end
end
local function collectRigAttachments(part)
local rigAttachments = {}
for _, child in pairs(part:GetChildren()) do
if child:IsA("Attachment") and child.Name:find("RigAttachment$") then
rigAttachments[child.Name] = child
end
end
-- Les os peuvent contenir des RigAttachments plus profonds qui remplacent les
-- RigAttachments au niveau de la pièce (squelette étendu R15+).
for _, child in pairs(part:GetChildren()) do
if child:IsA("Bone") then
for _, descendant in pairs(child:GetDescendants()) do
if descendant:IsA("Attachment") and descendant.Name:find("RigAttachment$") then
rigAttachments[descendant.Name] = descendant
end
end
end
end
return rigAttachments
end
local function buildJointsFromAttachments(part, characterParts, visitedParts)
if not part or visitedParts[part] then
return
end
visitedParts[part] = true
local rigAttachments = collectRigAttachments(part)
for attachmentName, attachment in pairs(rigAttachments) do
local jointName = attachmentName:sub(1, #attachmentName - #"RigAttachment")
if not part:FindFirstChild(jointName) then
for _, characterPart in pairs(characterParts) do
if not visitedParts[characterPart] then
local matchingAttachment = characterPart:FindFirstChild(attachmentName)
if matchingAttachment and matchingAttachment:IsA("Attachment") then
createJoint(jointName, attachment, matchingAttachment)
buildJointsFromAttachments(characterPart, characterParts, visitedParts)
break
end
end
end
end
end
end
local function buildRigFromAttachments(humanoid)
local rootPart = humanoid.RootPart
assert(rootPart, "Le Humanoid n'a pas de HumanoidRootPart.")
local characterParts = {}
for _, descendant in ipairs(humanoid.Parent:GetDescendants()) do
if descendant:IsA("BasePart") then
table.insert(characterParts, descendant)
end
end
local visitedParts = {}
buildJointsFromAttachments(rootPart, characterParts, visitedParts)
end
local humanoid = script.Parent:WaitForChild("Humanoid")
buildRigFromAttachments(humanoid)
Importateur de paquet R15
local AssetService = game:GetService("AssetService")
local InsertService = game:GetService("InsertService")
local MarketplaceService = game:GetService("MarketplaceService")
local PACKAGE_ASSET_ID = 193700907 -- Disjoncteur
local function addAttachment(part, name, position, orientation)
local attachment = Instance.new("Attachment")
attachment.Name = name
attachment.Parent = part
if position then
attachment.Position = position
end
if orientation then
attachment.Orientation = orientation
end
return attachment
end
local function createBaseCharacter()
local character = Instance.new("Model")
local humanoid = Instance.new("Humanoid")
humanoid.Parent = character
local rootPart = Instance.new("Part")
rootPart.Name = "HumanoidRootPart"
rootPart.Size = Vector3.new(2, 2, 1)
rootPart.Transparency = 1
rootPart.Parent = character
addAttachment(rootPart, "RootRigAttachment")
local head = Instance.new("Part")
head.Name = "Head"
head.Size = Vector3.new(2, 1, 1)
head.Parent = character
local headMesh = Instance.new("SpecialMesh")
headMesh.Scale = Vector3.new(1.25, 1.25, 1.25)
headMesh.MeshType = Enum.MeshType.Head
headMesh.Parent = head
local face = Instance.new("Decal")
face.Name = "face"
face.Texture = "rbxasset://textures/face.png"
face.Parent = head
addAttachment(head, "FaceCenterAttachment")
addAttachment(head, "FaceFrontAttachment", Vector3.new(0, 0, -0.6))
addAttachment(head, "HairAttachment", Vector3.new(0, 0.6, 0))
addAttachment(head, "HatAttachment", Vector3.new(0, 0.6, 0))
addAttachment(head, "NeckRigAttachment", Vector3.new(0, -0.5, 0))
return character, humanoid
end
local function createR15Package(packageAssetId)
local packageAssetInfo = MarketplaceService:GetProductInfoAsync(packageAssetId)
local character, humanoid = createBaseCharacter()
character.Name = packageAssetInfo.Name
local assetIds = AssetService:GetAssetIdsForPackageAsync(packageAssetId)
for _, assetId in pairs(assetIds) do
local limb = InsertService:LoadAsset(assetId)
local r15 = limb:FindFirstChild("R15")
if r15 then
for _, part in pairs(r15:GetChildren()) do
part.Parent = character
end
else
for _, child in pairs(limb:GetChildren()) do
child.Parent = character
end
end
end
humanoid:BuildRigFromAttachments()
return character
end
local r15Package = createR15Package(PACKAGE_ASSET_ID)
r15Package.Parent = workspace

ChangeState
Capacités : AvatarBehavior
Accès à la simulation
Humanoid:ChangeState(state:Enum.HumanoidStateType):()
Paramètres
Valeur par défaut : "None"
Retours
()
Échantillons de code
Double Saut
local UserInputService = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local doubleJumpEnabled = false
humanoid.StateChanged:Connect(function(_oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if not doubleJumpEnabled then
task.wait(0.2)
if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
doubleJumpEnabled = true
end
end
elseif newState == Enum.HumanoidStateType.Landed then
doubleJumpEnabled = false
end
end)
UserInputService.InputBegan:Connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.Space then
if doubleJumpEnabled then
if humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
task.spawn(function()
doubleJumpEnabled = false
end)
end
end
end
end)

EquipTool
Capacités : AvatarBehavior
Humanoid:EquipTool(tool:Instance):()
Paramètres
Retours
()

GetAccessories
Capacités : AvatarAppearance
Humanoid:GetAccessories():{any}
Retours
Échantillons de code
Supprimer les accessoires après le chargement
local Players = game:GetService("Players")
local function onPlayerAddedAsync(player)
local connection = player.CharacterAppearanceLoaded:Connect(function(character)
-- Tous les accessoires sont chargés à ce stade
local humanoid = character:FindFirstChildOfClass("Humanoid")
local numAccessories = #humanoid:GetAccessories()
print(("Destruction de %d accessoires pour %s"):format(numAccessories, player.Name))
humanoid:RemoveAccessories()
end)
-- Assurez-vous de déconnecter notre connexion au joueur après son départ
-- pour permettre au joueur d'être récupéré par le ramasse-miettes
player.AncestryChanged:Wait()
connection:Disconnect()
end
for _, player in Players:GetPlayers() do
task.spawn(onPlayerAddedAsync, player)
end
Players.PlayerAdded:Connect(onPlayerAddedAsync)

GetAppliedDescription
Capacités : AvatarAppearance
Humanoid:GetAppliedDescription():HumanoidDescription

GetBodyPartR15
Capacités : AvatarBehavior
Humanoid:GetBodyPartR15(part:Instance):Enum.BodyPartR15
Paramètres

GetLimb
Capacités : AvatarBehavior
Humanoid:GetLimb(part:Instance):Enum.Limb
Paramètres
Retours
Échantillons de code
Récupérer les membres d'un Humanoid
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
for _, child in pairs(character:GetChildren()) do
local limb = humanoid:GetLimb(child)
if limb ~= Enum.Limb.Unknown then
print(child.Name .. " fait partie du membre " .. limb.Name)
end
end

GetMoveVelocity
Capacités : AvatarBehavior
Humanoid:GetMoveVelocity():Vector3
Retours

GetPlayingAnimationTracks
Déprécié

GetRelativeVelocityAtFloor
Capacités : AvatarBehavior
Accès à la simulation
Humanoid:GetRelativeVelocityAtFloor():Vector3
Retours

GetState
Écrire en parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid:GetState():Enum.HumanoidStateType
Échantillons de code
Double Saut
local UserInputService = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local doubleJumpEnabled = false
humanoid.StateChanged:Connect(function(_oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if not doubleJumpEnabled then
task.wait(0.2)
if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
doubleJumpEnabled = true
end
end
elseif newState == Enum.HumanoidStateType.Landed then
doubleJumpEnabled = false
end
end)
UserInputService.InputBegan:Connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.Space then
if doubleJumpEnabled then
if humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
task.spawn(function()
doubleJumpEnabled = false
end)
end
end
end
end)

GetStateEnabled
Écrire en parallèle
Capacités : AvatarBehavior
Accès à la simulation
Humanoid:GetStateEnabled(state:Enum.HumanoidStateType):boolean
Paramètres
Retours
Échantillons de code
Définir et Obtenir les États Humanoïdes
local humanoid = script.Parent:WaitForChild("Humanoid")
-- Définir l'état
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
-- Obtenir l'état
print(humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping)) -- false

GetStatuses
Déprécié

HasCustomStatus
Déprécié

HasStatus
Déprécié

LoadAnimation
Déprécié

loadAnimation
Déprécié

Move
Capacités : AvatarBehavior
Accès à la simulation
Humanoid:Move(
moveDirection:Vector3, relativeToCamera:boolean
):()
Paramètres
moveDirection:Vector3
relativeToCamera:boolean
Valeur par défaut : false
Retours
()
Échantillons de code
Déplacer un Humanoïde vers l'avant
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
RunService:BindToRenderStep("move", Enum.RenderPriority.Character.Value + 1, function()
if player.Character then
local humanoid = player.Character:FindFirstChild("Humanoid")
if humanoid then
humanoid:Move(Vector3.new(0, 0, -1), true)
end
end
end)

MoveTo
Capacités : AvatarBehavior
Accès à la simulation
Humanoid:MoveTo(
location:Vector3, part:Instance
):()
Paramètres
location:Vector3
Valeur par défaut : "nil"
Retours
()
Échantillons de code
Humanoïde MoveTo sans délai
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- écouter lorsque le humanoïde atteint sa cible
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen(reached)
end
end)
-- commencer à marcher
humanoid:MoveTo(targetPoint)
-- exécuter sur un nouveau thread afin de ne pas faire attendre la fonction
task.spawn(function()
while not targetReached do
-- le humanoïde existe-t-il encore ?
if not (humanoid and humanoid.Parent) then
break
end
-- la cible a-t-elle changé ?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- actualiser le délai
humanoid:MoveTo(targetPoint)
task.wait(6)
end
-- déconnecter la connexion si elle est toujours connectée
if connection then
connection:Disconnect()
connection = nil
end
end)
end
local function andThen(reached)
print((reached and "Destination atteinte!") or "Échec d'atteindre la destination!")
end
moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)

PlayEmote
Déprécié

PlayEmoteAsync
Rendement
Capacités : AvatarBehavior
Humanoid:PlayEmoteAsync(emoteName:string):boolean
Paramètres
emoteName:string
Retours

RemoveAccessories
Capacités : AvatarAppearance
Humanoid:RemoveAccessories():()
Retours
()
Échantillons de code
Supprimer les accessoires après le chargement
local Players = game:GetService("Players")
local function onPlayerAddedAsync(player)
local connection = player.CharacterAppearanceLoaded:Connect(function(character)
-- Tous les accessoires sont chargés à ce stade
local humanoid = character:FindFirstChildOfClass("Humanoid")
local numAccessories = #humanoid:GetAccessories()
print(("Destruction de %d accessoires pour %s"):format(numAccessories, player.Name))
humanoid:RemoveAccessories()
end)
-- Assurez-vous de déconnecter notre connexion au joueur après son départ
-- pour permettre au joueur d'être récupéré par le ramasse-miettes
player.AncestryChanged:Wait()
connection:Disconnect()
end
for _, player in Players:GetPlayers() do
task.spawn(onPlayerAddedAsync, player)
end
Players.PlayerAdded:Connect(onPlayerAddedAsync)

RemoveCustomStatus
Déprécié

RemoveStatus
Déprécié

ReplaceBodyPartR15
Capacités : AvatarAppearance
Humanoid:ReplaceBodyPartR15(
bodyPart:Enum.BodyPartR15, part:BasePart
Paramètres
Retours

SetStateEnabled
Capacités : AvatarBehavior
Accès à la simulation
Humanoid:SetStateEnabled(
):()
Paramètres
enabled:boolean
Retours
()
Échantillons de code
Temps de recharge de saut
local character = script.Parent
local JUMP_DEBOUNCE = 1
local humanoid = character:WaitForChild("Humanoid")
local isJumping = false
humanoid.StateChanged:Connect(function(_oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if not isJumping then
isJumping = true
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end
elseif newState == Enum.HumanoidStateType.Landed then
if isJumping then
isJumping = false
task.wait(JUMP_DEBOUNCE)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
end
end)

TakeDamage
Capacités : AvatarBehavior
Humanoid:TakeDamage(amount:number):()
Paramètres
amount:number
Retours
()
Échantillons de code
Infliger des dommages à un Humanoïde
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid:TakeDamage(99)

takeDamage
Déprécié

UnequipTools
Capacités : AvatarBehavior
Humanoid:UnequipTools():()
Retours
()

Événements
AnimationPlayed
Déprécié

ApplyDescriptionFinished
Capacités : AvatarAppearance
Humanoid.ApplyDescriptionFinished(description:HumanoidDescription):RBXScriptSignal
Paramètres

Climbing
Capacités : AvatarBehavior
Humanoid.Climbing(speed:number):RBXScriptSignal
Paramètres
speed:number
Échantillons de code
Humanoïde.Grimpant
local Players = game:GetService("Players")
local function onCharacterClimbing(character, speed)
print(character.Name, "grimpe à une vitesse de", speed, "studs / seconde.")
end
local function onCharacterAdded(character)
character.Humanoid.Climbing:Connect(function(speed)
onCharacterClimbing(character, speed)
end)
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)

CustomStatusAdded
Déprécié

CustomStatusRemoved
Déprécié

Died
Capacités : AvatarBehavior
Humanoid.Died():RBXScriptSignal
Échantillons de code
Humanoid.Died
local Players = game:GetService("Players")
local function onPlayerAdded(player)
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
local function onDied()
print(player.Name, "est mort!")
end
humanoid.Died:Connect(onDied)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)

FallingDown
Capacités : AvatarBehavior
Humanoid.FallingDown(active:boolean):RBXScriptSignal
Paramètres
active:boolean

FreeFalling
Capacités : AvatarBehavior
Humanoid.FreeFalling(active:boolean):RBXScriptSignal
Paramètres
active:boolean

GettingUp
Capacités : AvatarBehavior
Humanoid.GettingUp(active:boolean):RBXScriptSignal
Paramètres
active:boolean

HealthChanged
Capacités : AvatarBehavior
Humanoid.HealthChanged(health:number):RBXScriptSignal
Paramètres
health:number
Échantillons de code
Humanoïde.SantéModifiée
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
local currentHealth = humanoid.Health
local function onHealthChanged(health)
local change = math.abs(currentHealth - health)
print("La santé de l'humanoïde", (currentHealth > health and "a diminué de" or "a augmenté de"), change)
currentHealth = health
end
humanoid.HealthChanged:Connect(onHealthChanged)
end
player.CharacterAdded:Connect(onCharacterAdded)
Barre de Vie
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Collez le script dans un LocalScript qui est
-- parenté à un Frame à l'intérieur d'un Frame
local frame = script.Parent
local container = frame.Parent
container.BackgroundColor3 = Color3.new(0, 0, 0) -- noir
-- Cette fonction est appelée lorsque la vie du humanoïde change
local function onHealthChanged()
local human = player.Character.Humanoid
local percent = human.Health / human.MaxHealth
-- Changez la taille de la barre intérieure
frame.Size = UDim2.new(percent, 0, 1, 0)
-- Changez la couleur de la barre de vie
if percent < 0.1 then
frame.BackgroundColor3 = Color3.new(1, 0, 0) -- rouge
elseif percent < 0.4 then
frame.BackgroundColor3 = Color3.new(1, 1, 0) -- jaune
else
frame.BackgroundColor3 = Color3.new(0, 1, 0) -- vert
end
end
-- Cette fonction est appelée lorsque le joueur apparaît
local function onCharacterAdded(character)
local human = character:WaitForChild("Humanoid")
-- Modèle : mise à jour une fois maintenant, puis chaque fois que la vie change
human.HealthChanged:Connect(onHealthChanged)
onHealthChanged()
end
-- Connectez notre écouteur de spawn ; appelez-le s'il est déjà apparu
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end

Jumping
Capacités : AvatarBehavior
Humanoid.Jumping(active:boolean):RBXScriptSignal
Paramètres
active:boolean

MoveToFinished
Capacités : AvatarBehavior
Humanoid.MoveToFinished(reached:boolean):RBXScriptSignal
Paramètres
reached:boolean
Échantillons de code
Humanoïde MoveTo sans délai
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- écouter lorsque le humanoïde atteint sa cible
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen(reached)
end
end)
-- commencer à marcher
humanoid:MoveTo(targetPoint)
-- exécuter sur un nouveau thread afin de ne pas faire attendre la fonction
task.spawn(function()
while not targetReached do
-- le humanoïde existe-t-il encore ?
if not (humanoid and humanoid.Parent) then
break
end
-- la cible a-t-elle changé ?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- actualiser le délai
humanoid:MoveTo(targetPoint)
task.wait(6)
end
-- déconnecter la connexion si elle est toujours connectée
if connection then
connection:Disconnect()
connection = nil
end
end)
end
local function andThen(reached)
print((reached and "Destination atteinte!") or "Échec d'atteindre la destination!")
end
moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)

PlatformStanding
Capacités : AvatarBehavior
Humanoid.PlatformStanding(active:boolean):RBXScriptSignal
Paramètres
active:boolean

Ragdoll
Capacités : AvatarBehavior
Humanoid.Ragdoll(active:boolean):RBXScriptSignal
Paramètres
active:boolean

Running
Capacités : AvatarBehavior
Humanoid.Running(speed:number):RBXScriptSignal
Paramètres
speed:number
Échantillons de code
Humanoïde en Course
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local function onRunning(speed: number)
if speed > 0 then
print(`{localPlayer.Name} est en train de courir`)
else
print(`{localPlayer.Name} s'est arrêté`)
end
end
humanoid.Running:Connect(function(speed: number)
onRunning(speed)
end)

Seated
Capacités : AvatarBehavior
Humanoid.Seated(
active:boolean, currentSeatPart:BasePart
Paramètres
active:boolean
currentSeatPart:BasePart
Échantillons de code
Trouver le siège d'un joueur
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local function onSeated(isSeated, seat)
if isSeated then
print("Je suis maintenant assis sur : " .. seat.Name .. " !")
else
print("Je ne suis assis sur rien")
end
end
humanoid.Seated:Connect(onSeated)

StateChanged
Capacités : AvatarBehavior
Échantillons de code
Particules sautillantes
local character = script.Parent
local primaryPart = character.PrimaryPart
-- créer des particules
local particles = Instance.new("ParticleEmitter")
particles.Size = NumberSequence.new(1)
particles.Transparency = NumberSequence.new(0, 1)
particles.Acceleration = Vector3.new(0, -10, 0)
particles.Lifetime = NumberRange.new(1)
particles.Rate = 20
particles.EmissionDirection = Enum.NormalId.Back
particles.Enabled = false
particles.Parent = primaryPart
local humanoid = character:WaitForChild("Humanoid")
local isJumping = false
-- écouter l'état du humanoïde
local function onStateChanged(_oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if not isJumping then
isJumping = true
particles.Enabled = true
end
elseif newState == Enum.HumanoidStateType.Landed then
if isJumping then
isJumping = false
particles.Enabled = false
end
end
end
humanoid.StateChanged:Connect(onStateChanged)
Temps de recharge de saut
local character = script.Parent
local JUMP_DEBOUNCE = 1
local humanoid = character:WaitForChild("Humanoid")
local isJumping = false
humanoid.StateChanged:Connect(function(_oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if not isJumping then
isJumping = true
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end
elseif newState == Enum.HumanoidStateType.Landed then
if isJumping then
isJumping = false
task.wait(JUMP_DEBOUNCE)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
end
end)

StateEnabledChanged
Capacités : AvatarBehavior
Humanoid.StateEnabledChanged(
Paramètres
isEnabled:boolean
Échantillons de code
Détecteur de changement d'état humanoïde
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local function onStateEnabledChanged(state, enabled)
if enabled then
print(state.Name .. " a été activé")
else
print(state.Name .. " a été désactivé")
end
end
humanoid.StateEnabledChanged:Connect(onStateEnabledChanged)

StatusAdded
Déprécié

StatusRemoved
Déprécié

Strafing
Capacités : AvatarBehavior
Humanoid.Strafing(active:boolean):RBXScriptSignal
Paramètres
active:boolean

Swimming
Capacités : AvatarBehavior
Humanoid.Swimming(speed:number):RBXScriptSignal
Paramètres
speed:number

Touched
Capacités : AvatarBehavior
Humanoid.Touched(
touchingPart:BasePart, humanoidPart:BasePart
Paramètres
touchingPart:BasePart
humanoidPart:BasePart
Échantillons de code
Toucher de Midas
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local partInfo = {}
local debounce = false
local function onHumanoidTouched(hit, _limb)
if debounce then
return
end
if not hit.CanCollide or hit.Transparency ~= 0 then
return
end
if not partInfo[hit] then
partInfo[hit] = {
BrickColor = hit.BrickColor,
Material = hit.Material,
}
hit.BrickColor = BrickColor.new("Or")
hit.Material = Enum.Material.Ice
debounce = true
task.wait(0.2)
debounce = false
end
end
local touchedConnection = humanoid.Touched:Connect(onHumanoidTouched)
local function onHumanoidDied()
if touchedConnection then
touchedConnection:Disconnect()
end
-- annuler tout l'or
for part, info in pairs(partInfo) do
if part and part.Parent then
part.BrickColor = info.BrickColor
part.Material = info.Material
end
end
end
humanoid.Died:Connect(onHumanoidDied)

©2026 Société Roblox. Roblox, le logo Roblox et Powering Imagination font partie de nos marques déposées aux États-Unis et dans d'autres pays.