Roblox

[Roblox] Script로 Humanoid 조작하기

TigerFish 2024. 1. 1. 15:18

글을 쓰는 목적

 

Humanoid 조작


작업 환경 

 

로블록스 : 0.605


 

Humanoid 얻어오기 

 

1. Humanoid를 조작하기 위해 패드 생성 

2. 파츠에 Script 추가

3. 파츠에 GUI 추가 

https://tigerfish.tistory.com/322

 

[Roblox] Part에 UI 추가하기

글을 쓰는 목적 Part에 UI 추가하는 방법을 기록한다. 작업 환경 Roblox : 0.605 1. Part 에 SurfaceGui 컴포넌트 추가 2. SurfaceGui에 Face에 원하는 위치에 표시하도록 설정 3. 추가하고 싶은 GUI Component를 추가

tigerfish.tistory.com

4. FindFistChildOfClass에서 Humanoid를 얻어 오기

local ownerPart = script.Parent
local humanoid = ownerPart:FindFirstChildOfClass("Humanoid")

Humanoid 속도 높이기

 

1. humanoid의 walkspeed 변경 

local ownerPart = script.Parent

function OnSpeedUp(otherPart)
	local character = otherPart.Parent
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if humanoid and humanoid.WalkSpeed <= 16 then
		humanoid.WalkSpeed = 32
		wait(5)
		humanoid.WalkSpeed = 16
	end
end

ownerPart.Touched:Connect(OnSpeedUp)

Humanoid 점프 변경

 

1. Humanoid의 JumpPower 변경

local ownerPart = script.Parent

function OnJumpUp(player)
	local character = player.Parent
	local humanoid = character:FindFirstChildOfClass("Humanoid")

	if humanoid and humanoid.JumpPower <= 50 then
		humanoid.UseJumpPower = true
		humanoid.JumpPower = 500
		wait(5)
		humanoid.JumpPower = 50
	end
end

ownerPart.Touched:Connect(OnJumpUp)

Humanoid 죽음

 

1. Humanoid의 Health 0으로 변경

local ownerPart = script.Parent

function OnKillCharacter(Character)
	local character = Character.Parent
	local humanoid = character:FindFirstChild("Humanoid")
	if humanoid ~= nil then
		humanoid.Health = 0
	end
end

ownerPart.Touched:Connect(OnKillCharacter)

Humanoid 신체 크기 변경

 

1. Humanoid에 GetAppliedDescription을 통해 신체 크기 변경 

local ownerPart = script.Parent

local function OnSizeUpHead(InCharacter)
	local character = InCharacter.Parent
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		local appliedDescription = humanoid:GetAppliedDescription()
		local originScale = appliedDescription.HeadScale
		appliedDescription.HeadScale = 3

		humanoid:ApplyDescription(appliedDescription)

		wait(5)

		appliedDescription.HeadScale = originScale

		humanoid:ApplyDescription(appliedDescription)
	end
end

ownerPart.Touched:Connect(OnSizeUpHead)