เรียนรู้
Engine Class
Humanoid

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
วิธีการ
AddAccessory(accessory: Instance):()
AddCustomStatus(status: string):boolean
เลิกใช้แล้ว
AddStatus(status: Enum.Status):boolean
เลิกใช้แล้ว
ApplyDescription(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
เลิกใช้แล้ว
ApplyDescriptionAsync(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
ApplyDescriptionReset(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
เลิกใช้แล้ว
ApplyDescriptionResetAsync(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
GetPlayingAnimationTracks():{any}
เลิกใช้แล้ว
GetStatuses():{any}
เลิกใช้แล้ว
HasCustomStatus(status: string):boolean
เลิกใช้แล้ว
HasStatus(status: Enum.Status):boolean
เลิกใช้แล้ว
LoadAnimation(animation: Animation):AnimationTrack
เลิกใช้แล้ว
loadAnimation(animation: Animation):AnimationTrack
เลิกใช้แล้ว
Move(moveDirection: Vector3,relativeToCamera: boolean):()
MoveTo(location: Vector3,part: Instance):()
PlayEmote(emoteName: string):boolean
เลิกใช้แล้ว
RemoveCustomStatus(status: string):boolean
เลิกใช้แล้ว
RemoveStatus(status: Enum.Status):boolean
เลิกใช้แล้ว
TakeDamage(amount: number):()
takeDamage(amount: number):()
เลิกใช้แล้ว
สมาชิกที่ได้รับทอด
ตัวอย่างโค้ด
เอฟเฟกต์กล้องบอบเบิ้ลขณะเดิน
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 -- ตัวละครกำลังเดินอยู่หรือเปล่า?
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
-- ลดขนาด CameraOffset เพื่อให้มันกลับไปยังตำแหน่งปกติ
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
AutoJumpEnabled
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.AutoJumpEnabled:boolean
ตัวอย่างโค้ด
ปิด/เปิดการกระโดดโดยอัตโนมัติ
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local button = script.Parent
local function update()
-- อัปเดตข้อความบนปุ่ม
if player.AutoJumpEnabled then
button.Text = "การกระโดดโดยอัตโนมัติเปิดอยู่"
else
button.Text = "การกระโดดโดยอัตโนมัติปิดอยู่"
end
-- สะท้อนคุณสมบัติในตัวละครของผู้เล่น หากพวกเขามี
if player.Character then
local human = player.Character:FindFirstChild("Humanoid")
if human then
human.AutoJumpEnabled = player.AutoJumpEnabled
end
end
end
local function onActivated()
-- สลับการกระโดดโดยอัตโนมัติ
player.AutoJumpEnabled = not player.AutoJumpEnabled
-- อัปเดตทุกอย่างอื่น
update()
end
button.Activated:Connect(onActivated)
update()

AutomaticScalingEnabled
อ่านพร้อมๆ กัน
ความสามารถ: AvatarAppearance
Humanoid.AutomaticScalingEnabled:boolean

AutoRotate
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.AutoRotate:boolean
ตัวอย่างโค้ด
ปุ่มหมุนอัตโนมัติ
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() .. " ไม่สามารถหมุนอัตโนมัติได้อีกต่อไป!")
humanoid.AutoRotate = false
else
print(humanoid:GetFullName() .. " สามารถหมุนอัตโนมัติได้แล้ว!")
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
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
Humanoid.BreakJointsOnDeath:boolean

CameraOffset
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
Humanoid.CameraOffset:Vector3
ตัวอย่างโค้ด
เอฟเฟกต์กล้องบอบเบิ้ลขณะเดิน
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 -- ตัวละครกำลังเดินอยู่หรือเปล่า?
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
-- ลดขนาด CameraOffset เพื่อให้มันกลับไปยังตำแหน่งปกติ
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)

CollisionType
เลิกใช้แล้ว

DisplayDistanceType
อ่านพร้อมๆ กัน
ความสามารถ: AvatarAppearance
Humanoid.DisplayDistanceType:Enum.HumanoidDisplayDistanceType
ตัวอย่างโค้ด
แสดงสุขภาพและชื่อของ Humanoid
local humanoid = script.Parent
humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.Viewer
humanoid.HealthDisplayDistance = 0
humanoid.NameDisplayDistance = 100

DisplayName
อ่านพร้อมๆ กัน
ความสามารถ: AvatarAppearance
Humanoid.DisplayName:string

EvaluateStateMachine
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.EvaluateStateMachine:boolean

FloorMaterial
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.FloorMaterial:Enum.Material

Health
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
Humanoid.Health:number

HealthDisplayDistance
อ่านพร้อมๆ กัน
ความสามารถ: AvatarAppearance
Humanoid.HealthDisplayDistance:number

HealthDisplayType
อ่านพร้อมๆ กัน
ความสามารถ: AvatarAppearance
Humanoid.HealthDisplayType:Enum.HumanoidHealthDisplayType

HipHeight
อ่านพร้อมๆ กัน
ความสามารถ: AvatarAppearance
การเข้าถึงการจำลองสถานการณ์
Humanoid.HipHeight:number

Jump
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.Jump:boolean

JumpHeight
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.JumpHeight:number

JumpPower
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.JumpPower:number

LeftLeg
เลิกใช้แล้ว

MaxHealth
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
Humanoid.MaxHealth:number

maxHealth
เลิกใช้แล้ว

MaxSlopeAngle
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
Humanoid.MaxSlopeAngle:number
ตัวอย่างโค้ด
การจำกัดความชันที่มนุษย์สามารถเดินขึ้นได้
local player = game.Players.LocalPlayer
local char = player.CharacterAdded:wait()
local h = char:FindFirstChild("Humanoid")
h.MaxSlopeAngle = 30

MoveDirection
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.MoveDirection:Vector3
ตัวอย่างโค้ด
เอฟเฟกต์กล้องบอบเบิ้ลขณะเดิน
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 -- ตัวละครกำลังเดินอยู่หรือเปล่า?
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
-- ลดขนาด CameraOffset เพื่อให้มันกลับไปยังตำแหน่งปกติ
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)

NameDisplayDistance
อ่านพร้อมๆ กัน
ความสามารถ: AvatarAppearance
Humanoid.NameDisplayDistance:number

NameOcclusion
อ่านพร้อมๆ กัน
ความสามารถ: AvatarAppearance
Humanoid.NameOcclusion:Enum.NameOcclusion
ตัวอย่างโค้ด
ซ่อนชื่อผู้เล่น
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
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
Humanoid.PlatformStand:boolean

RequiresNeck
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
Humanoid.RequiresNeck:boolean

RightLeg
เลิกใช้แล้ว

RigType
อ่านพร้อมๆ กัน
ความสามารถ: AvatarAppearance
Humanoid.RigType:Enum.HumanoidRigType

RootPart
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.RootPart:BasePart

SeatPart
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.SeatPart:BasePart

Sit
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.Sit:boolean

TargetPoint
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
Humanoid.TargetPoint:Vector3

Torso
เลิกใช้แล้ว

UseJumpPower
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.UseJumpPower:boolean

WalkSpeed
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.WalkSpeed:number

WalkToPart
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
Humanoid.WalkToPart:BasePart

WalkToPoint
อ่านพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid.WalkToPoint:Vector3

วิธีการ
AddAccessory
ความสามารถ: AvatarAppearance
Humanoid:AddAccessory(accessory:Instance):()
พารามิเตอร์
accessory:Instance
ส่งค่ากลับ
()
ตัวอย่างโค้ด
[Humanoid] ตัวอย่างการเพิ่มอุปกรณ์เสริม
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
เลิกใช้แล้ว

AddStatus
เลิกใช้แล้ว

ApplyDescription
เลิกใช้แล้ว

ApplyDescriptionAsync
ผลตอบแทน
ความสามารถ: AvatarAppearance
Humanoid:ApplyDescriptionAsync(
humanoidDescription:HumanoidDescription, assetTypeVerification:Enum.AssetTypeVerification
):()
พารามิเตอร์
humanoidDescription:HumanoidDescription
assetTypeVerification:Enum.AssetTypeVerification
ค่าเริ่มต้น: "Default"
ส่งค่ากลับ
()

ApplyDescriptionReset
เลิกใช้แล้ว

ApplyDescriptionResetAsync
ผลตอบแทน
ความสามารถ: AvatarAppearance
Humanoid:ApplyDescriptionResetAsync(
humanoidDescription:HumanoidDescription, assetTypeVerification:Enum.AssetTypeVerification
):()
พารามิเตอร์
humanoidDescription:HumanoidDescription
assetTypeVerification:Enum.AssetTypeVerification
ค่าเริ่มต้น: "Default"
ส่งค่ากลับ
()

BuildRigFromAttachments
ความสามารถ: AvatarBehavior
Humanoid:BuildRigFromAttachments():()
ส่งค่ากลับ
()
ตัวอย่างโค้ด
พอร์ต Lua ของ 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
-- กระดูกอาจมี RigAttachments ที่ลึกกว่า ซึ่งจะแทนที่ระดับพาร์ต
-- (กระดูกโครงกระดูกขยาย 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 ไม่มี 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)
เครื่องนำเข้าแพ็คเกจ R15
local AssetService = game:GetService("AssetService")
local InsertService = game:GetService("InsertService")
local MarketplaceService = game:GetService("MarketplaceService")
local PACKAGE_ASSET_ID = 193700907 -- เบรกเกอร์เซอร์กิต
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
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid:ChangeState(state:Enum.HumanoidStateType):()
พารามิเตอร์
ค่าเริ่มต้น: "None"
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การกระโดดสองครั้ง
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
ความสามารถ: AvatarBehavior
Humanoid:EquipTool(tool:Instance):()
พารามิเตอร์
ส่งค่ากลับ
()

GetAccessories
ความสามารถ: AvatarAppearance
Humanoid:GetAccessories():{any}
ส่งค่ากลับ
ตัวอย่างโค้ด
ลบอุปกรณ์หลังจากโหลดเสร็จแล้ว
local Players = game:GetService("Players")
local function onPlayerAddedAsync(player)
local connection = player.CharacterAppearanceLoaded:Connect(function(character)
-- อุปกรณ์ทั้งหมดได้โหลดเสร็จแล้วในจุดนี้
local humanoid = character:FindFirstChildOfClass("Humanoid")
local numAccessories = #humanoid:GetAccessories()
print(("กำลังลบอุปกรณ์ %d ชิ้นสำหรับ %s"):format(numAccessories, player.Name))
humanoid:RemoveAccessories()
end)
-- ต้องแน่ใจว่าเราได้ตัดการเชื่อมต่อจากผู้เล่นหลังจากที่พวกเขาออก
-- เพื่อให้ผู้เล่นสามารถถูกเก็บขยะได้
player.AncestryChanged:Wait()
connection:Disconnect()
end
for _, player in Players:GetPlayers() do
task.spawn(onPlayerAddedAsync, player)
end
Players.PlayerAdded:Connect(onPlayerAddedAsync)

GetAppliedDescription
ความสามารถ: AvatarAppearance
Humanoid:GetAppliedDescription():HumanoidDescription
ส่งค่ากลับ

GetBodyPartR15
ความสามารถ: AvatarBehavior
Humanoid:GetBodyPartR15(part:Instance):Enum.BodyPartR15
พารามิเตอร์
ส่งค่ากลับ

GetLimb
ความสามารถ: AvatarBehavior
Humanoid:GetLimb(part:Instance):Enum.Limb
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
การดึงแขนขาของ 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 .. " เป็นส่วนหนึ่งของแขนขา " .. limb.Name)
end
end

GetMoveVelocity
ความสามารถ: AvatarBehavior
Humanoid:GetMoveVelocity():Vector3
ส่งค่ากลับ

GetPlayingAnimationTracks
เลิกใช้แล้ว

GetRelativeVelocityAtFloor
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid:GetRelativeVelocityAtFloor():Vector3
ส่งค่ากลับ

GetState
เขียนพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid:GetState():Enum.HumanoidStateType
ส่งค่ากลับ
ตัวอย่างโค้ด
การกระโดดสองครั้ง
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
เขียนพร้อมๆ กัน
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid:GetStateEnabled(state:Enum.HumanoidStateType):boolean
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
การตั้งค่าและรับสถานะของ Humanoid
local humanoid = script.Parent:WaitForChild("Humanoid")
-- ตั้งค่าสถานะ
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
-- รับสถานะ
print(humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping)) -- false

GetStatuses
เลิกใช้แล้ว

HasCustomStatus
เลิกใช้แล้ว

HasStatus
เลิกใช้แล้ว

LoadAnimation
เลิกใช้แล้ว

loadAnimation
เลิกใช้แล้ว

Move
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid:Move(
moveDirection:Vector3, relativeToCamera:boolean
):()
พารามิเตอร์
moveDirection:Vector3
relativeToCamera:boolean
ค่าเริ่มต้น: false
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การเคลื่อนที่ของ Humanoid ไปข้างหน้า
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
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid:MoveTo(
location:Vector3, part:Instance
):()
พารามิเตอร์
location:Vector3
ค่าเริ่มต้น: "nil"
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การเคลื่อนที่ของ Humanoid โดยไม่หมดเวลา
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- เฝ้าฟังเมื่อ humanoid ถึงเป้าหมาย
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen(reached)
end
end)
-- เริ่มเดิน
humanoid:MoveTo(targetPoint)
-- ทำงานในเธรดใหม่เพื่อไม่ให้ยอมแพ้ฟังก์ชัน
task.spawn(function()
while not targetReached do
-- humanoid ยังมีอยู่หรือไม่?
if not (humanoid and humanoid.Parent) then
break
end
-- เป้าหมายเปลี่ยนหรือไม่?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- รีเฟรชการหมดเวลา
humanoid:MoveTo(targetPoint)
task.wait(6)
end
-- ตัดการเชื่อมต่อหากยังเชื่อมต่ออยู่
if connection then
connection:Disconnect()
connection = nil
end
end)
end
local function andThen(reached)
print((reached and "ถึงจุดหมายแล้ว!") or "ไม่สามารถไปถึงจุดหมายได้!")
end
moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)

PlayEmote
เลิกใช้แล้ว

PlayEmoteAsync
ผลตอบแทน
ความสามารถ: AvatarBehavior
Humanoid:PlayEmoteAsync(emoteName:string):boolean
พารามิเตอร์
emoteName:string
ส่งค่ากลับ

RemoveAccessories
ความสามารถ: AvatarAppearance
Humanoid:RemoveAccessories():()
ส่งค่ากลับ
()
ตัวอย่างโค้ด
ลบอุปกรณ์หลังจากโหลดเสร็จแล้ว
local Players = game:GetService("Players")
local function onPlayerAddedAsync(player)
local connection = player.CharacterAppearanceLoaded:Connect(function(character)
-- อุปกรณ์ทั้งหมดได้โหลดเสร็จแล้วในจุดนี้
local humanoid = character:FindFirstChildOfClass("Humanoid")
local numAccessories = #humanoid:GetAccessories()
print(("กำลังลบอุปกรณ์ %d ชิ้นสำหรับ %s"):format(numAccessories, player.Name))
humanoid:RemoveAccessories()
end)
-- ต้องแน่ใจว่าเราได้ตัดการเชื่อมต่อจากผู้เล่นหลังจากที่พวกเขาออก
-- เพื่อให้ผู้เล่นสามารถถูกเก็บขยะได้
player.AncestryChanged:Wait()
connection:Disconnect()
end
for _, player in Players:GetPlayers() do
task.spawn(onPlayerAddedAsync, player)
end
Players.PlayerAdded:Connect(onPlayerAddedAsync)

RemoveCustomStatus
เลิกใช้แล้ว

RemoveStatus
เลิกใช้แล้ว

ReplaceBodyPartR15
ความสามารถ: AvatarAppearance
Humanoid:ReplaceBodyPartR15(
bodyPart:Enum.BodyPartR15, part:BasePart
พารามิเตอร์
ส่งค่ากลับ

SetStateEnabled
ความสามารถ: AvatarBehavior
การเข้าถึงการจำลองสถานการณ์
Humanoid:SetStateEnabled(
):()
พารามิเตอร์
enabled:boolean
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การรีเซ็ตการกระโดด
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
ความสามารถ: AvatarBehavior
Humanoid:TakeDamage(amount:number):()
พารามิเตอร์
amount:number
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การทำให้ฮิวมานอยด์ได้รับความเสียหาย
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
เลิกใช้แล้ว

UnequipTools
ความสามารถ: AvatarBehavior
Humanoid:UnequipTools():()
ส่งค่ากลับ
()

เหตุการณ์
AnimationPlayed
เลิกใช้แล้ว

ApplyDescriptionFinished
ความสามารถ: AvatarAppearance
Humanoid.ApplyDescriptionFinished(description:HumanoidDescription):RBXScriptSignal
พารามิเตอร์

Climbing
ความสามารถ: AvatarBehavior
Humanoid.Climbing(speed:number):RBXScriptSignal
พารามิเตอร์
speed:number
ตัวอย่างโค้ด
Humanoid.ปีน
local Players = game:GetService("Players")
local function onCharacterClimbing(character, speed)
print(character.Name, "กำลังปีนด้วยความเร็ว", speed, "สตัด / วินาที.")
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
เลิกใช้แล้ว

CustomStatusRemoved
เลิกใช้แล้ว

Died
ความสามารถ: AvatarBehavior
Humanoid.Died():RBXScriptSignal
ตัวอย่างโค้ด
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, "ได้เสียชีวิตแล้ว!")
end
humanoid.Died:Connect(onDied)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)

FallingDown
ความสามารถ: AvatarBehavior
Humanoid.FallingDown(active:boolean):RBXScriptSignal
พารามิเตอร์
active:boolean

FreeFalling
ความสามารถ: AvatarBehavior
Humanoid.FreeFalling(active:boolean):RBXScriptSignal
พารามิเตอร์
active:boolean

GettingUp
ความสามารถ: AvatarBehavior
Humanoid.GettingUp(active:boolean):RBXScriptSignal
พารามิเตอร์
active:boolean

HealthChanged
ความสามารถ: AvatarBehavior
Humanoid.HealthChanged(health:number):RBXScriptSignal
พารามิเตอร์
health:number
ตัวอย่างโค้ด
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("สุขภาพของมนุษย์", (currentHealth > health and "ลดลงโดย" or "เพิ่มขึ้นโดย"), change)
currentHealth = health
end
humanoid.HealthChanged:Connect(onHealthChanged)
end
player.CharacterAdded:Connect(onCharacterAdded)
แถบสุขภาพ
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- วางสคริปต์ลงใน LocalScript ที่
-- ถูกทำให้เป็นพ่อของเฟรมภายในเฟรม
local frame = script.Parent
local container = frame.Parent
container.BackgroundColor3 = Color3.new(0, 0, 0) -- สีดำ
-- ฟังก์ชันนี้จะถูกเรียกเมื่อสุขภาพของมนุษย์เปลี่ยนแปลง
local function onHealthChanged()
local human = player.Character.Humanoid
local percent = human.Health / human.MaxHealth
-- เปลี่ยนขนาดของแถบภายใน
frame.Size = UDim2.new(percent, 0, 1, 0)
-- เปลี่ยนสีของแถบสุขภาพ
if percent < 0.1 then
frame.BackgroundColor3 = Color3.new(1, 0, 0) -- สีดำ
elseif percent < 0.4 then
frame.BackgroundColor3 = Color3.new(1, 1, 0) -- สีเหลือง
else
frame.BackgroundColor3 = Color3.new(0, 1, 0) -- สีเขียว
end
end
-- ฟังก์ชันนี้จะถูกเรียกเมื่อผู้เล่นเกิดขึ้น
local function onCharacterAdded(character)
local human = character:WaitForChild("Humanoid")
-- รูปแบบ: อัปเดตหนึ่งครั้งตอนนี้ จากนั้นทุกครั้งที่สุขภาพเปลี่ยนแปลง
human.HealthChanged:Connect(onHealthChanged)
onHealthChanged()
end
-- เชื่อมต่อผู้ฟังการเกิดของเรา; เรียกใช้งานหากเกิดขึ้นแล้ว
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end

Jumping
ความสามารถ: AvatarBehavior
Humanoid.Jumping(active:boolean):RBXScriptSignal
พารามิเตอร์
active:boolean

MoveToFinished
ความสามารถ: AvatarBehavior
Humanoid.MoveToFinished(reached:boolean):RBXScriptSignal
พารามิเตอร์
reached:boolean
ตัวอย่างโค้ด
การเคลื่อนที่ของ Humanoid โดยไม่หมดเวลา
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- เฝ้าฟังเมื่อ humanoid ถึงเป้าหมาย
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen(reached)
end
end)
-- เริ่มเดิน
humanoid:MoveTo(targetPoint)
-- ทำงานในเธรดใหม่เพื่อไม่ให้ยอมแพ้ฟังก์ชัน
task.spawn(function()
while not targetReached do
-- humanoid ยังมีอยู่หรือไม่?
if not (humanoid and humanoid.Parent) then
break
end
-- เป้าหมายเปลี่ยนหรือไม่?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- รีเฟรชการหมดเวลา
humanoid:MoveTo(targetPoint)
task.wait(6)
end
-- ตัดการเชื่อมต่อหากยังเชื่อมต่ออยู่
if connection then
connection:Disconnect()
connection = nil
end
end)
end
local function andThen(reached)
print((reached and "ถึงจุดหมายแล้ว!") or "ไม่สามารถไปถึงจุดหมายได้!")
end
moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)

PlatformStanding
ความสามารถ: AvatarBehavior
Humanoid.PlatformStanding(active:boolean):RBXScriptSignal
พารามิเตอร์
active:boolean

Ragdoll
ความสามารถ: AvatarBehavior
Humanoid.Ragdoll(active:boolean):RBXScriptSignal
พารามิเตอร์
active:boolean

Running
ความสามารถ: AvatarBehavior
Humanoid.Running(speed:number):RBXScriptSignal
พารามิเตอร์
speed:number
ตัวอย่างโค้ด
มนุษย์วิ่ง
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} กำลังวิ่ง`)
else
print(`{localPlayer.Name} หยุดแล้ว`)
end
end
humanoid.Running:Connect(function(speed: number)
onRunning(speed)
end)

Seated
ความสามารถ: AvatarBehavior
Humanoid.Seated(
active:boolean, currentSeatPart:BasePart
พารามิเตอร์
active:boolean
currentSeatPart:BasePart
ตัวอย่างโค้ด
ค้นหาที่นั่งของผู้เล่น
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local function onSeated(isSeated, seat)
if isSeated then
print("ตอนนี้ฉันนั่งอยู่บน: " .. seat.Name .. "!")
else
print("ตอนนี้ฉันไม่ได้ sitting บนอะไร")
end
end
humanoid.Seated:Connect(onSeated)

StateChanged
ความสามารถ: AvatarBehavior
พารามิเตอร์
ตัวอย่างโค้ด
การกระโดดของอนุภาค
local character = script.Parent
local primaryPart = character.PrimaryPart
-- สร้างอนุภาค
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
-- ฟังสถานะของฮิวมานอยด์
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)
การรีเซ็ตการกระโดด
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
ความสามารถ: AvatarBehavior
Humanoid.StateEnabledChanged(
พารามิเตอร์
isEnabled:boolean
ตัวอย่างโค้ด
ตัวตรวจจับการเปลี่ยนแปลงสถานะมนุษย์
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 .. " ถูกเปิดใช้งาน")
else
print(state.Name .. " ถูกปิดการใช้งาน")
end
end
humanoid.StateEnabledChanged:Connect(onStateEnabledChanged)

StatusAdded
เลิกใช้แล้ว

StatusRemoved
เลิกใช้แล้ว

Strafing
ความสามารถ: AvatarBehavior
Humanoid.Strafing(active:boolean):RBXScriptSignal
พารามิเตอร์
active:boolean

Swimming
ความสามารถ: AvatarBehavior
Humanoid.Swimming(speed:number):RBXScriptSignal
พารามิเตอร์
speed:number

Touched
ความสามารถ: AvatarBehavior
Humanoid.Touched(
touchingPart:BasePart, humanoidPart:BasePart
พารามิเตอร์
touchingPart:BasePart
humanoidPart:BasePart
ตัวอย่างโค้ด
สัมผัสของไมดาส
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("ทอง")
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
-- ยกเลิกทั้งหมดที่เป็นทอง
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, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ