Shirt
*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.
O objeto Shirt mostra uma textura de camisa do Roblox em um Humanoid rig / plataforma / equipamento.Camisas cobrem o torso e os braços e terão prioridade sobre um Pants no torso.Para ser visível, um Shirt deve ser um irmão de um Humanoid e ter sua propriedade ShirtTemplate definida para uma textura apropriada, como rbxassetid://86896487.A textura da camisa pode ser colorida usando a propriedade Clothing.Color3.
Camisas são carregadas automaticamente em Player caracteres se seu avatar estiver usando uma.
Amostras de código
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.
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
Resumo
Propriedades
ShirtTemplate
O link de ID de conteúdo apontando para o modelo de camisa hospedado no Roblox.
Esse ID de conteúdo é diferente do URL do site da camisa.Pode ser encontrado ao colar o URL do site da camisa na propriedade Modelo de Camisa no Studio.Alternativamente, InsertService:LoadAsset() pode ser usado para inserir a camisa no espaço de trabalho, por exemplo:
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
Veja também ShirtGraphic.Graphic para a imagem aplicada a camisetas.
Amostras de código
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.
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