Shirt

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

Shirt 对象在 Humanoid 骨架上显示 Roblox 的衬衫纹理。衬衫覆盖躯干和手臂,将在躯干上优先于 Pants 。要可见,一个 Shirt 必须是 Humanoid 的兄弟,并将其 ShirtTemplate 属性设置为适当的纹理,例如 rbxassetid://86896487 。衬衫纹理可以使用 Clothing.Color3 属性进行颜色化。

如果他们的虚拟形象穿着了一件衬衫,就会在 Player 字符上自动加载衬衫。

代码示例

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

属性

ShirtTemplate

ContentId
读取并联

指向 Roblox 上托管的衬衫模板的内容 ID 链接。

该内容 ID 与衬衫网站 URL 不同。它可以通过将衬衫网站 URL 粘贴到 Studio 的 衬衫模板 属性中找到。或者,InsertService:LoadAsset() 可以用来将衬衫插入工作区,例如:


local InsertService = game:GetService("InsertService")
local Workspace = game:GetService("Workspace")
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 InsertService:LoadAsset(assetId)
end)
if success then
model.Parent = Workspace
end

也参阅ShirtGraphic.Graphic对T恤衫应用的图像。

代码示例

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

方法

活动