Pants

Hiển Thị Bản Đã Lỗi Thời

*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.

Vật phẩm Pants hiển thị một kết cấu quần từ Roblox trên một Humanoid giàn.Quần bao phủ phần thân và chân, và sẽ được bao phủ bởi một Shirt trên phần thân.Để có thể nhìn thấy, một Pants phải là em của một Humanoid và có bộ thuộc tính PantsTemplate của nó được đặt thành một kết cấu thích hợp như rbxassetid://86896501.Vải quần có thể được màu hóa bằng cách sử dụng thuộc tính Clothing.Color3.

Quần tự động được tải trên Player nhân vật nếu avatar của họ đang mặc một.

Mẫu mã

This sample includes a simple function to change the texture of the Shirt and Pants worn by a player's character. If shirt and pants don't exist then they are created. Note, this should be run every time the character spawns. If a developer is looking to permanently change a character's appearance to a preset it is recommended they use Player.CharacterAppearance.

Change Shirt / Pants

local Players = game:GetService("Players")
local function replaceClothes(player)
local character = player.Character
if character then
-- look for shirts / pants
local shirt = character:FindFirstChildOfClass("Shirt")
local pants = character:FindFirstChildOfClass("Pants")
-- create shirts / pants if they don't exist
if not shirt then
shirt = Instance.new("Shirt")
shirt.Parent = character
end
if not pants then
pants = Instance.new("Pants")
pants.Parent = character
end
-- reset shirt / pants content ids
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=83326831"
pants.PantsTemplate = "http://www.roblox.com/asset/?id=10045638"
end
end
for _index, player in ipairs(Players:GetPlayers()) do
replaceClothes(player)
end

Thuộc Tính

PantsTemplate

ContentId
Đọc Song Song

Liên kết ID nội dung chỉ vào mẫu quần được lưu trữ trên Roblox.

ID nội dung này khác với URL trang web của quần.Nó có thể được tìm thấy bằng cách dán URL trang web của quần vào thuộc tính PantsTemplate trong Studio.Thay thế, InsertService:LoadAsset() có thể được sử dụng để chèn quần vào không gian làm việc, ví dụ:


local InsertService = game:GetService("InsertService")
local Workspace = game:GetService("Workspace")
local webURL = "https://www.roblox.com/catalog/1804739/Jeans"
local assetId = tonumber(string.match(webURL, "%d+") or 0) -- Extract the number
local success, model = pcall(function()
return InsertService:LoadAsset(assetId)
end)
if success then
model.Parent = Workspace
end

Đối với mẫu của một đối tượng Shirt, xem Shirt.ShirtTemplate.

Mẫu mã

This sample includes a simple function to change the texture of the Shirt and Pants worn by a player's character. If shirt and pants don't exist then they are created. Note, this should be run every time the character spawns. If a developer is looking to permanently change a character's appearance to a preset it is recommended they use Player.CharacterAppearance.

Change Shirt / Pants

local Players = game:GetService("Players")
local function replaceClothes(player)
local character = player.Character
if character then
-- look for shirts / pants
local shirt = character:FindFirstChildOfClass("Shirt")
local pants = character:FindFirstChildOfClass("Pants")
-- create shirts / pants if they don't exist
if not shirt then
shirt = Instance.new("Shirt")
shirt.Parent = character
end
if not pants then
pants = Instance.new("Pants")
pants.Parent = character
end
-- reset shirt / pants content ids
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=83326831"
pants.PantsTemplate = "http://www.roblox.com/asset/?id=10045638"
end
end
for _index, player in ipairs(Players:GetPlayers()) do
replaceClothes(player)
end

Phương Pháp

Sự Kiện