Roblox

[Roblox] Script로 Shirts Pants 변경하기

TigerFish 2024. 1. 1. 20:21

글을 쓰는 목적 

 

Shirt, Pants 조작하기를 기록한다. 


작업 환경

 

Roblox : 0.605


옷 변경

 

1. 홈 - 도구 상자 - 마켓플레이스  - 이미지 검색 얻고 싶은 asset id 얻어오거나 이미지 추가하여 asset id 추가

 

2. Character에 AssetId를 담을 StringValue 추가(AssetId는 "rbxassetid://1234" 형식으로 추가)

3. Character Script 추가

4. Character에 FindFirstChild로 Shirt와 Pants 컴포넌트를 찾은 후 Template를 변경하여 설정

local ownerPart = script.Parent
local shirtId = ownerPart:FindFirstChild("ShirtIdString").Value
local pantsId = ownerPart:FindFirstChild("PantsIdString").Value

local function OnChangeClothes(InCharacter)
	local humanoid = InCharacter.Parent:FindFirstChild("Humanoid")
	if humanoid then
		local character = InCharacter.Parent
		if character then
			local shirt = character:FindFirstChildOfClass("Shirt")
			local pants = character:FindFirstChildOfClass("Pants")
						
			pants.PantsTemplate = pantsId
			print("pants template id : " .. pantsId)

			shirt.ShirtTemplate = shirtId
			print("shirt template id : " .. shirtId)
			
		end
	end
end

ownerPart.Touched:Connect(OnChangeClothes)

'Roblox' 카테고리의 다른 글

[Roblox] Script로 Humanoid 조작하기  (0) 2024.01.01
[Roblox] Script로 파츠 조작하기  (0) 2023.12.31
[Roblox] Part에 SurfaceGui 추가하기  (0) 2023.12.27
[Roblox] 지형 만들기 및 편집  (0) 2023.12.23