Humanoid 메서드 및 속성
Empty
Empty
Empty
TakeDamage | Humanoid의 건강을 지정된 양만큼 줄입니다. |
MoveTo | Humanoid가 지정된 위치나 부품으로 이동하도록 합니다. |
GetState | Enum.HumanoidStateType 유형의 현재 상태를 반환합니다. |
ChangeState | Humanoid를 지정된 상태로 강제 전환합니다. |
RemoveAccessories | Humanoid의 부모 모델이 착용한 모든 액세서리를 제거합니다. |
ReplaceBodyPartR15 | R15 신체 부품을 다른 부품으로 교체합니다. |
SetStateEnabled | Humanoid의 지정된 상태를 활성화하거나 비활성화합니다. |
UnequipTools | Humanoid가 현재 장착한 도구를 해제합니다. |
ApplyDescription | Humanoid에 HumanoidDescription을 적용합니다. |
ApplyDescriptionReset | Humanoid에 HumanoidDescription을 적용하고 모든 변경 사항을 재설정합니다. |
PlayEmote | 유효한 경우 지정된 감정 표현을 재생합니다. |
Move | Humanoid가 지정된 방향으로 이동하도록 합니다. |
GetMoveVelocity | Humanoid의 현재 이동 속도를 반환합니다. |
EquipTool | Humanoid에 지정된 도구를 장착합니다. |
Empty
Empty
Empty
Health | Humanoid의 현재 건강 상태를 나타냅니다. |
MaxHealth | Humanoid가 가질 수 있는 최대 건강 상태를 나타냅니다. |
WalkSpeed | Humanoid가 걸을 수 있는 속도를 결정합니다. |
JumpPower | Humanoid의 점프력을 제어합니다. |
HipHeight | Humanoid의 엉덩이가 지면에서 떨어진 높이입니다. |
AutoRotate | Humanoid가 이동 방향을 향해 자동으로 회전할지 여부를 결정합니다. |
BreakJointsOnDeath | Humanoid가 죽을 때 관절이 파손될지 여부를 제어합니다. |
CameraOffset | Humanoid에 상대적인 카메라 오프셋입니다. |
FloorMaterial | Humanoid가 서 있는 바닥의 재질 유형을 나타냅니다. |
NameDisplayDistance | Humanoid의 이름이 표시되는 거리입니다. |
NameOcclusion | 이름표가 표시되는 방식을 결정합니다. |
Sit | Humanoid가 앉아 있는지 여부를 나타냅니다. |
TargetPoint | Humanoid가 이동하는 목표 지점입니다. |
Humanoid 건강 예제
Empty
Empty
Empty
local Players = game:GetService("Players")
local function onPlayerAdded(player)
-- Wait for the player's character to load
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- Example: Setting Health
print("Current Health:", humanoid.Health)
humanoid.Health = 50 -- Set health to 50
print("New Health:", humanoid.Health)
-- Example: Adding Health
print("Current Health:", humanoid.Health)
local healthToAdd = 20
humanoid.Health = math.min(humanoid.Health + healthToAdd, humanoid.MaxHealth)
print("Health after adding health:", humanoid.Health)
-- Example: Checking if Humanoid is Dead
humanoid.Died:Connect(function()
print("Humanoid has died!")
end)
-- Example: Changing MaxHealth
print("Current MaxHealth:", humanoid.MaxHealth)
humanoid.MaxHealth = 200 -- Set MaxHealth to 200
print("New MaxHealth:", humanoid.MaxHealth)
-- Example: Setting Health to MaxHealth
humanoid.Health = humanoid.MaxHealth
print("Health set to MaxHealth:", humanoid.Health)
-- Example: Taking Damage
print("Current Health:", humanoid.Health)
humanoid.Health = humanoid.Health - 300 -- Directly reduce health by 300
print("Health after taking damage:", humanoid.Health)
end
-- Connect the function to the PlayerAdded event
Players.PlayerAdded:Connect(onPlayerAdded)
Roblox Studio
Humanoid 애니메이션 예제
Empty
Empty
Empty
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- Animation setup
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://131036267483527" -- Replace with your animation asset ID
-- Load the animation onto the humanoid
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack.Looped = false -- Ensure the animation does not loop by default
-- Function to play the animation
local function playAnimation()
print("playAnimation")
animationTrack:Play()
end
-- Function to stop the animation
local function stopAnimation()
print("stopAnimation")
animationTrack:Stop()
end
-- Function to loop the animation
local function loopAnimation(loopCount)
animationTrack.Looped = true
animationTrack:Play()
print("loopAnimation")
-- Stop looping after the specified count
delay(loopCount * animationTrack.Length, function()
animationTrack.Looped = false
stopAnimation()
print("loopAnimation stopped")
end)
end
-- Detect when "P", "T", or "L" is pressed and trigger the appropriate function
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.P and not gameProcessedEvent then
print("pressed P")
playAnimation()
end
if input.KeyCode == Enum.KeyCode.T and not gameProcessedEvent then
print("pressed T")
stopAnimation()
end
if input.KeyCode == Enum.KeyCode.L and not gameProcessedEvent then
print("pressed L")
loopAnimation(3)
end
end)
Roblox Studio
Humanoid 이동 예제
Empty
Empty
Empty
-- Function to make the humanoid walk to a specific point
local function walkToPoint(point)
humanoid:MoveTo(point)
end
-- Function to make the humanoid move in a specific direction
local function moveInDirection(direction)
humanoid:Move(direction)
end
-- Function to stop the humanoid's movement
local function stopMovement()
humanoid:Move(Vector3.new(0, 0, 0))
end
-- Example usage
local targetPoint = Vector3.new(10, 0, 10) -- Define a target point
walkToPoint(targetPoint) -- Make the humanoid walk to the target point
-- After a delay, make the humanoid move in a specific direction
wait(2)
local direction = Vector3.new(1, 0, 0) -- Define a direction
moveInDirection(direction)
-- After a delay, stop the humanoid's movement
wait(2)
stopMovement()
Roblox Studio
Empty
Empty
Empty
- Humanoid:MoveTo를 사용할 때, Humanoid는 자동으로 적절한 걷기 또는 달리기 애니메이션을 재생합니다.
- 이 메서드는 Humanoid의 내부 상태를 걷기 또는 달리기로 설정하고, 목표에 도달하거나 이동이 중단되면 다시 대기 상태로 전환됩니다.
- Humanoid가 목적지에 도달하거나 특정 시간 내에 도달하지 못할 경우 MoveToFinished 이벤트가 발생합니다.
Humanoid 이벤트 예제
Empty
Empty
Empty
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- Function to handle when the humanoid finishes moving to a point
humanoid.MoveToFinished:Connect(function(reached)
if reached then
print("Humanoid reached the destination")
else
print("Humanoid did not reach the destination")
end
end)
-- Example function stubs for each event
local function onDied()
print("Humanoid died")
end
local function onRunning(speed)
print("Humanoid is running at speed:", speed)
end
local function onJumping()
print("Humanoid is jumping")
end
local function onClimbing()
print("Humanoid is climbing")
end
local function onGettingUp()
print("Humanoid is getting up")
end
local function onFreeFalling()
print("Humanoid is in free fall")
end
local function onFallingDown()
print("Humanoid is falling down")
end
local function onSeated()
print("Humanoid is seated")
end
local function onPlatformStanding()
print("Humanoid is platform standing")
end
local function onSwimming()
print("Humanoid is swimming")
end
-- Connect the functions to the respective humanoid events
humanoid.Died:Connect(onDied)
humanoid.Running:Connect(onRunning)
humanoid.Jumping:Connect(onJumping)
humanoid.Climbing:Connect(onClimbing)
humanoid.GettingUp:Connect(onGettingUp)
humanoid.FreeFalling:Connect(onFreeFalling)
humanoid.FallingDown:Connect(onFallingDown)
humanoid.Seated:Connect(onSeated)
humanoid.PlatformStanding:Connect(onPlatformStanding)
humanoid.Swimming:Connect(onSwimming)
Roblox Studio