Shirt 对象显示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
属性
ShirtTemplate
ContentId
指向 Roblox 上的服装模板的内容 ID。
此内容ID与上衣网站的URL不同。它可以通过将上衣网站的URL粘贴到 Studio中的ShirtTemplate属性中找到。或者,InsertService:LoadAsset()可以用来将上衣插入工作区,例如:
local webURL = "https://www.roblox.com/catalog/1804747/White-Shirt"
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
请参阅ShirtGraphic.Graphic 对T恤的图像。
代码示例
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