Pants 对象显示 Humanoid
如果他们的头像穿戴了裤子,则在 Player 角色上自动加载裤子。
代码示例
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
属性
PantsTemplate
ContentId
指向 Roblox 上的裤子模板的内容 ID。
此内容ID与裤子网站的URL不同。它可以通过将裤子网站的URL粘贴到 Studio的 裤子模板 属性中找到。或者,InsertService:LoadAsset() 可以用来将裤子插入工作区,例如:
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 game:GetService("InsertService"):LoadAsset(assetId)
end)
if success then
model.Parent = workspace
end
对于一个 Shirt 对象的模板,请参阅 Shirt.ShirtTemplate 。
代码示例
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
属性继承自Clothing