Ghi chú phát hành
Học
Lớp công cụ
Humanoid

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm Tắt
Phương Pháp
AddAccessory(accessory: Instance):()
AddCustomStatus(status: string):boolean
Đã Lỗi Thời
AddStatus(status: Enum.Status):boolean
Đã Lỗi Thời
ApplyDescription(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
Đã Lỗi Thời
ApplyDescriptionAsync(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
ApplyDescriptionReset(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
Đã Lỗi Thời
ApplyDescriptionResetAsync(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
GetPlayingAnimationTracks():{any}
Đã Lỗi Thời
GetStatuses():{any}
Đã Lỗi Thời
HasCustomStatus(status: string):boolean
Đã Lỗi Thời
HasStatus(status: Enum.Status):boolean
Đã Lỗi Thời
LoadAnimation(animation: Animation):AnimationTrack
Đã Lỗi Thời
loadAnimation(animation: Animation):AnimationTrack
Đã Lỗi Thời
Move(moveDirection: Vector3,relativeToCamera: boolean):()
MoveTo(location: Vector3,part: Instance):()
PlayEmote(emoteName: string):boolean
Đã Lỗi Thời
RemoveCustomStatus(status: string):boolean
Đã Lỗi Thời
RemoveStatus(status: Enum.Status):boolean
Đã Lỗi Thời
TakeDamage(amount: number):()
takeDamage(amount: number):()
Đã Lỗi Thời
Thành viên kế thừa
Mẫu mã
Hiệu ứng lắc camera khi đi bộ
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 -- Nhân vật có đang đi không?
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
-- Giảm CameraOffset để nó dịch về vị trí bình thường.
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)

Tài Liệu Tham Khảo API
Thuộc Tính
AutoJumpEnabled
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.AutoJumpEnabled:boolean
Mẫu mã
Chuyển đổi Tự Nhảy
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local button = script.Parent
local function update()
-- Cập nhật văn bản nút
if player.AutoJumpEnabled then
button.Text = "Tự Nhảy đã BẬT"
else
button.Text = "Tự Nhảy đã TẮT"
end
-- Phản ánh thuộc tính trong nhân vật của người chơi, nếu họ có
if player.Character then
local human = player.Character:FindFirstChild("Humanoid")
if human then
human.AutoJumpEnabled = player.AutoJumpEnabled
end
end
end
local function onActivated()
-- Chuyển đổi tự nhảy
player.AutoJumpEnabled = not player.AutoJumpEnabled
-- Cập nhật mọi thứ khác
update()
end
button.Activated:Connect(onActivated)
update()

AutomaticScalingEnabled
Đọc Song Song
Các khả năng: AvatarAppearance
Humanoid.AutomaticScalingEnabled:boolean

AutoRotate
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.AutoRotate:boolean
Mẫu mã
Nút Tự Động Xoay
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() .. " không còn tự động xoay nữa!")
humanoid.AutoRotate = false
else
print(humanoid:GetFullName() .. " bây giờ có thể tự động xoay!")
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
Đọc Song Song
Các khả năng: AvatarBehavior
Humanoid.BreakJointsOnDeath:boolean

CameraOffset
Đọc Song Song
Các khả năng: AvatarBehavior
Humanoid.CameraOffset:Vector3
Mẫu mã
Hiệu ứng lắc camera khi đi bộ
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 -- Nhân vật có đang đi không?
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
-- Giảm CameraOffset để nó dịch về vị trí bình thường.
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)

CollisionType
Đã Lỗi Thời

DisplayDistanceType
Đọc Song Song
Các khả năng: AvatarAppearance
Humanoid.DisplayDistanceType:Enum.HumanoidDisplayDistanceType
Mẫu mã
Hiển thị sức khỏe và tên của một Humanoid
local humanoid = script.Parent
humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.Viewer
humanoid.HealthDisplayDistance = 0
humanoid.NameDisplayDistance = 100

DisplayName
Đọc Song Song
Các khả năng: AvatarAppearance
Humanoid.DisplayName:string

EvaluateStateMachine
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.EvaluateStateMachine:boolean

FloorMaterial
Chỉ Đọc
Không Sao Chép
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.FloorMaterial:Enum.Material

Health
Không Sao Chép
Đọc Song Song
Các khả năng: AvatarBehavior
Humanoid.Health:number

HealthDisplayDistance
Đọc Song Song
Các khả năng: AvatarAppearance
Humanoid.HealthDisplayDistance:number

HealthDisplayType
Đọc Song Song
Các khả năng: AvatarAppearance
Humanoid.HealthDisplayType:Enum.HumanoidHealthDisplayType

HipHeight
Đọc Song Song
Các khả năng: AvatarAppearance
Quyền sử dụng chế độ mô phỏng
Humanoid.HipHeight:number

Jump
Không Sao Chép
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.Jump:boolean

JumpHeight
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.JumpHeight:number

JumpPower
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.JumpPower:number

LeftLeg
Đã Lỗi Thời

MaxHealth
Đọc Song Song
Các khả năng: AvatarBehavior
Humanoid.MaxHealth:number

maxHealth
Đã Lỗi Thời

MaxSlopeAngle
Đọc Song Song
Các khả năng: AvatarBehavior
Humanoid.MaxSlopeAngle:number
Mẫu mã
Giới Hạn Độ Dốc mà Một Humanoid Có Thể Đi Lên
local player = game.Players.LocalPlayer
local char = player.CharacterAdded:wait()
local h = char:FindFirstChild("Humanoid")
h.MaxSlopeAngle = 30

MoveDirection
Chỉ Đọc
Không Sao Chép
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.MoveDirection:Vector3
Mẫu mã
Hiệu ứng lắc camera khi đi bộ
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 -- Nhân vật có đang đi không?
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
-- Giảm CameraOffset để nó dịch về vị trí bình thường.
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)

NameDisplayDistance
Đọc Song Song
Các khả năng: AvatarAppearance
Humanoid.NameDisplayDistance:number

NameOcclusion
Đọc Song Song
Các khả năng: AvatarAppearance
Humanoid.NameOcclusion:Enum.NameOcclusion
Mẫu mã
Ngăn Chặn Tên Người Chơi
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
Đọc Song Song
Các khả năng: AvatarBehavior
Humanoid.PlatformStand:boolean

RequiresNeck
Đọc Song Song
Các khả năng: AvatarBehavior
Humanoid.RequiresNeck:boolean

RightLeg
Đã Lỗi Thời

RigType
Đọc Song Song
Các khả năng: AvatarAppearance
Humanoid.RigType:Enum.HumanoidRigType

RootPart
Chỉ Đọc
Không Sao Chép
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.RootPart:BasePart

SeatPart
Chỉ Đọc
Không Sao Chép
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.SeatPart:BasePart

Sit
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.Sit:boolean

TargetPoint
Đọc Song Song
Các khả năng: AvatarBehavior
Humanoid.TargetPoint:Vector3

Torso
Đã Lỗi Thời

UseJumpPower
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.UseJumpPower:boolean

WalkSpeed
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.WalkSpeed:number

WalkToPart
Đọc Song Song
Các khả năng: AvatarBehavior
Humanoid.WalkToPart:BasePart

WalkToPoint
Đọc Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid.WalkToPoint:Vector3

Phương Pháp
AddAccessory
Các khả năng: AvatarAppearance
Humanoid:AddAccessory(accessory:Instance):()
Tham Số
accessory:Instance
Lợi Nhuận
()
Mẫu mã
[Humanoid] Ví dụ về AddAccessory
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
Đã Lỗi Thời

AddStatus
Đã Lỗi Thời

ApplyDescription
Đã Lỗi Thời

ApplyDescriptionAsync
Sinh Lợi
Các khả năng: AvatarAppearance
Humanoid:ApplyDescriptionAsync(
humanoidDescription:HumanoidDescription, assetTypeVerification:Enum.AssetTypeVerification
):()
Tham Số
humanoidDescription:HumanoidDescription
assetTypeVerification:Enum.AssetTypeVerification
Giá Trị Mặc Định: "Default"
Lợi Nhuận
()

ApplyDescriptionReset
Đã Lỗi Thời

ApplyDescriptionResetAsync
Sinh Lợi
Các khả năng: AvatarAppearance
Humanoid:ApplyDescriptionResetAsync(
humanoidDescription:HumanoidDescription, assetTypeVerification:Enum.AssetTypeVerification
):()
Tham Số
humanoidDescription:HumanoidDescription
assetTypeVerification:Enum.AssetTypeVerification
Giá Trị Mặc Định: "Default"
Lợi Nhuận
()

BuildRigFromAttachments
Các khả năng: AvatarBehavior
Humanoid:BuildRigFromAttachments():()
Lợi Nhuận
()
Mẫu mã
Cổng Lua của 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
-- Xương có thể chứa các RigAttachments sâu hơn có thể ghi đè lên
-- các RigAttachments ở cấp độ phần (cơ thể mở rộng 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, "Humanoid không có 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)
Bộ Nhập Gói R15
local AssetService = game:GetService("AssetService")
local InsertService = game:GetService("InsertService")
local MarketplaceService = game:GetService("MarketplaceService")
local PACKAGE_ASSET_ID = 193700907 -- Bộ ngắt mạch
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
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid:ChangeState(state:Enum.HumanoidStateType):()
Tham Số
Giá Trị Mặc Định: "None"
Lợi Nhuận
()
Mẫu mã
Nhảy Gấp Đôi
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
Các khả năng: AvatarBehavior
Humanoid:EquipTool(tool:Instance):()
Tham Số
Lợi Nhuận
()

GetAccessories
Các khả năng: AvatarAppearance
Humanoid:GetAccessories():{any}
Lợi Nhuận
Mẫu mã
Xóa Phụ Kiện Sau Khi Tải
local Players = game:GetService("Players")
local function onPlayerAddedAsync(player)
local connection = player.CharacterAppearanceLoaded:Connect(function(character)
-- Tất cả phụ kiện đã được tải tại thời điểm này
local humanoid = character:FindFirstChildOfClass("Humanoid")
local numAccessories = #humanoid:GetAccessories()
print(("Đang xóa %d phụ kiện cho %s"):format(numAccessories, player.Name))
humanoid:RemoveAccessories()
end)
-- Đảm bảo chúng ta ngắt kết nối kết nối với người chơi sau khi họ rời đi
-- để cho phép người chơi được thu gom rác
player.AncestryChanged:Wait()
connection:Disconnect()
end
for _, player in Players:GetPlayers() do
task.spawn(onPlayerAddedAsync, player)
end
Players.PlayerAdded:Connect(onPlayerAddedAsync)

GetAppliedDescription
Các khả năng: AvatarAppearance
Humanoid:GetAppliedDescription():HumanoidDescription
Lợi Nhuận

GetBodyPartR15
Các khả năng: AvatarBehavior
Humanoid:GetBodyPartR15(part:Instance):Enum.BodyPartR15
Tham Số
Lợi Nhuận

GetLimb
Các khả năng: AvatarBehavior
Humanoid:GetLimb(part:Instance):Enum.Limb
Tham Số
Lợi Nhuận
Mẫu mã
Lấy Chi Nhánh của 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 .. " là một phần của chi " .. limb.Name)
end
end

GetMoveVelocity
Các khả năng: AvatarBehavior
Humanoid:GetMoveVelocity():Vector3
Lợi Nhuận

GetPlayingAnimationTracks
Đã Lỗi Thời

GetRelativeVelocityAtFloor
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid:GetRelativeVelocityAtFloor():Vector3
Lợi Nhuận

GetState
Ghi Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid:GetState():Enum.HumanoidStateType
Mẫu mã
Nhảy Gấp Đôi
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
Ghi Song Song
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid:GetStateEnabled(state:Enum.HumanoidStateType):boolean
Tham Số
Lợi Nhuận
Mẫu mã
Cài đặt và Lấy Trạng thái Humanoid
local humanoid = script.Parent:WaitForChild("Humanoid")
-- Đặt trạng thái
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
-- Lấy trạng thái
print(humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping)) -- false

GetStatuses
Đã Lỗi Thời

HasCustomStatus
Đã Lỗi Thời

HasStatus
Đã Lỗi Thời

LoadAnimation
Đã Lỗi Thời

loadAnimation
Đã Lỗi Thời

Move
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid:Move(
moveDirection:Vector3, relativeToCamera:boolean
):()
Tham Số
moveDirection:Vector3
relativeToCamera:boolean
Giá Trị Mặc Định: false
Lợi Nhuận
()
Mẫu mã
Di chuyển một Humanoid về phía trước
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
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid:MoveTo(
location:Vector3, part:Instance
):()
Tham Số
location:Vector3
Giá Trị Mặc Định: "nil"
Lợi Nhuận
()
Mẫu mã
Di chuyển Nhân cách không có Thời gian chờ
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- lắng nghe nhân cách đạt đến mục tiêu của nó
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen(reached)
end
end)
-- bắt đầu đi bộ
humanoid:MoveTo(targetPoint)
-- thực hiện trên một luồng mới để không làm dừng hàm
task.spawn(function()
while not targetReached do
-- liệu nhân cách vẫn tồn tại?
if not (humanoid and humanoid.Parent) then
break
end
-- liệu mục tiêu đã thay đổi chưa?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- làm mới thời gian chờ
humanoid:MoveTo(targetPoint)
task.wait(6)
end
-- ngắt kết nối nếu nó vẫn đang được kết nối
if connection then
connection:Disconnect()
connection = nil
end
end)
end
local function andThen(reached)
print((reached and "Đã đạt đến đích!") or "Không thể đạt đến đích!")
end
moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)

PlayEmote
Đã Lỗi Thời

PlayEmoteAsync
Sinh Lợi
Các khả năng: AvatarBehavior
Humanoid:PlayEmoteAsync(emoteName:string):boolean
Tham Số
emoteName:string
Lợi Nhuận

RemoveAccessories
Các khả năng: AvatarAppearance
Humanoid:RemoveAccessories():()
Lợi Nhuận
()
Mẫu mã
Xóa Phụ Kiện Sau Khi Tải
local Players = game:GetService("Players")
local function onPlayerAddedAsync(player)
local connection = player.CharacterAppearanceLoaded:Connect(function(character)
-- Tất cả phụ kiện đã được tải tại thời điểm này
local humanoid = character:FindFirstChildOfClass("Humanoid")
local numAccessories = #humanoid:GetAccessories()
print(("Đang xóa %d phụ kiện cho %s"):format(numAccessories, player.Name))
humanoid:RemoveAccessories()
end)
-- Đảm bảo chúng ta ngắt kết nối kết nối với người chơi sau khi họ rời đi
-- để cho phép người chơi được thu gom rác
player.AncestryChanged:Wait()
connection:Disconnect()
end
for _, player in Players:GetPlayers() do
task.spawn(onPlayerAddedAsync, player)
end
Players.PlayerAdded:Connect(onPlayerAddedAsync)

RemoveCustomStatus
Đã Lỗi Thời

RemoveStatus
Đã Lỗi Thời

ReplaceBodyPartR15
Các khả năng: AvatarAppearance
Humanoid:ReplaceBodyPartR15(
bodyPart:Enum.BodyPartR15, part:BasePart
Tham Số
Lợi Nhuận

SetStateEnabled
Các khả năng: AvatarBehavior
Quyền sử dụng chế độ mô phỏng
Humanoid:SetStateEnabled(
):()
Tham Số
enabled:boolean
Lợi Nhuận
()
Mẫu mã
Thời gian hồi chiêu nhảy
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
Các khả năng: AvatarBehavior
Humanoid:TakeDamage(amount:number):()
Tham Số
amount:number
Lợi Nhuận
()
Mẫu mã
Gây sát thương cho một Humanoid
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
Đã Lỗi Thời

UnequipTools
Các khả năng: AvatarBehavior
Humanoid:UnequipTools():()
Lợi Nhuận
()

Sự Kiện
AnimationPlayed
Đã Lỗi Thời

ApplyDescriptionFinished
Các khả năng: AvatarAppearance
Humanoid.ApplyDescriptionFinished(description:HumanoidDescription):RBXScriptSignal
Tham Số

Climbing
Các khả năng: AvatarBehavior
Humanoid.Climbing(speed:number):RBXScriptSignal
Tham Số
speed:number
Mẫu mã
Humanoid.Climbing
local Players = game:GetService("Players")
local function onCharacterClimbing(character, speed)
print(character.Name, "đang leo với tốc độ", speed, "studs / giây.")
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
Đã Lỗi Thời

CustomStatusRemoved
Đã Lỗi Thời

Died
Các khả năng: AvatarBehavior
Humanoid.Died():RBXScriptSignal
Mẫu mã
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, "đã chết!")
end
humanoid.Died:Connect(onDied)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)

FallingDown
Các khả năng: AvatarBehavior
Humanoid.FallingDown(active:boolean):RBXScriptSignal
Tham Số
active:boolean

FreeFalling
Các khả năng: AvatarBehavior
Humanoid.FreeFalling(active:boolean):RBXScriptSignal
Tham Số
active:boolean

GettingUp
Các khả năng: AvatarBehavior
Humanoid.GettingUp(active:boolean):RBXScriptSignal
Tham Số
active:boolean

HealthChanged
Các khả năng: AvatarBehavior
Humanoid.HealthChanged(health:number):RBXScriptSignal
Tham Số
health:number
Mẫu mã
Humanoid.HealthChanged
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("Sức khỏe của humanoid", (currentHealth > health and "giảm" or "tăng"), change)
currentHealth = health
end
humanoid.HealthChanged:Connect(onHealthChanged)
end
player.CharacterAdded:Connect(onCharacterAdded)
Thẻ Sức Khỏe
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Dán mã vào một LocalScript được
-- gán làm cha cho một khung bên trong khung
local frame = script.Parent
local container = frame.Parent
container.BackgroundColor3 = Color3.new(0, 0, 0) -- đen
-- Hàm này được gọi khi sức khỏe của humanoid thay đổi
local function onHealthChanged()
local human = player.Character.Humanoid
local percent = human.Health / human.MaxHealth
-- Thay đổi kích thước của thanh bên trong
frame.Size = UDim2.new(percent, 0, 1, 0)
-- Thay đổi màu sắc của thẻ sức khỏe
if percent < 0.1 then
frame.BackgroundColor3 = Color3.new(1, 0, 0) -- đỏ
elseif percent < 0.4 then
frame.BackgroundColor3 = Color3.new(1, 1, 0) -- vàng
else
frame.BackgroundColor3 = Color3.new(0, 1, 0) -- xanh
end
end
-- Hàm này được gọi khi người chơi xuất hiện
local function onCharacterAdded(character)
local human = character:WaitForChild("Humanoid")
-- Cách thức: cập nhật một lần bây giờ, sau đó bất kỳ lúc nào sức khỏe thay đổi
human.HealthChanged:Connect(onHealthChanged)
onHealthChanged()
end
-- Kết nối trình nghe cho lần xuất hiện; gọi nó nếu đã xuất hiện
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end

Jumping
Các khả năng: AvatarBehavior
Humanoid.Jumping(active:boolean):RBXScriptSignal
Tham Số
active:boolean

MoveToFinished
Các khả năng: AvatarBehavior
Humanoid.MoveToFinished(reached:boolean):RBXScriptSignal
Tham Số
reached:boolean
Mẫu mã
Di chuyển Nhân cách không có Thời gian chờ
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- lắng nghe nhân cách đạt đến mục tiêu của nó
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen(reached)
end
end)
-- bắt đầu đi bộ
humanoid:MoveTo(targetPoint)
-- thực hiện trên một luồng mới để không làm dừng hàm
task.spawn(function()
while not targetReached do
-- liệu nhân cách vẫn tồn tại?
if not (humanoid and humanoid.Parent) then
break
end
-- liệu mục tiêu đã thay đổi chưa?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- làm mới thời gian chờ
humanoid:MoveTo(targetPoint)
task.wait(6)
end
-- ngắt kết nối nếu nó vẫn đang được kết nối
if connection then
connection:Disconnect()
connection = nil
end
end)
end
local function andThen(reached)
print((reached and "Đã đạt đến đích!") or "Không thể đạt đến đích!")
end
moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)

PlatformStanding
Các khả năng: AvatarBehavior
Humanoid.PlatformStanding(active:boolean):RBXScriptSignal
Tham Số
active:boolean

Ragdoll
Các khả năng: AvatarBehavior
Humanoid.Ragdoll(active:boolean):RBXScriptSignal
Tham Số
active:boolean

Running
Các khả năng: AvatarBehavior
Humanoid.Running(speed:number):RBXScriptSignal
Tham Số
speed:number
Mẫu mã
Chạy Nhân Tạo
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} đang chạy`)
else
print(`{localPlayer.Name} đã dừng lại`)
end
end
humanoid.Running:Connect(function(speed: number)
onRunning(speed)
end)

Seated
Các khả năng: AvatarBehavior
Humanoid.Seated(
active:boolean, currentSeatPart:BasePart
Tham Số
active:boolean
currentSeatPart:BasePart
Mẫu mã
Tìm Ghế Của Người Chơi
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local function onSeated(isSeated, seat)
if isSeated then
print("Tôi hiện đang ngồi trên: " .. seat.Name .. "!")
else
print("Tôi không ngồi trên gì cả")
end
end
humanoid.Seated:Connect(onSeated)

StateChanged
Các khả năng: AvatarBehavior
Mẫu mã
Phần Tử Nhảy
local character = script.Parent
local primaryPart = character.PrimaryPart
-- tạo phần tử
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
-- lắng nghe trạng thái của humanoid
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)
Thời gian hồi chiêu nhảy
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
Các khả năng: AvatarBehavior
Humanoid.StateEnabledChanged(
Tham Số
isEnabled:boolean
Mẫu mã
Bộ Phát Hiện Thay Đổi Trạng Thái Nhân Hoá
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 .. " đã được kích hoạt")
else
print(state.Name .. " đã bị vô hiệu")
end
end
humanoid.StateEnabledChanged:Connect(onStateEnabledChanged)

StatusAdded
Đã Lỗi Thời

StatusRemoved
Đã Lỗi Thời

Strafing
Các khả năng: AvatarBehavior
Humanoid.Strafing(active:boolean):RBXScriptSignal
Tham Số
active:boolean

Swimming
Các khả năng: AvatarBehavior
Humanoid.Swimming(speed:number):RBXScriptSignal
Tham Số
speed:number

Touched
Các khả năng: AvatarBehavior
Humanoid.Touched(
touchingPart:BasePart, humanoidPart:BasePart
Tham Số
touchingPart:BasePart
humanoidPart:BasePart
Mẫu mã
Chạm 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("Vàng")
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
-- hoàn tác tất cả vàng
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 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.