Shirt

Afficher les obsolètes

*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.

L'objet Shirt affiche une texture de chemise de Roblox sur une Humanoid plateforme.Les chemises couvrent le torse et les bras, et prendront la priorité sur un Pants sur le torse.Pour être visible, un Shirt doit être le frère d'un Humanoid et avoir sa propriété ShirtTemplate définie sur une texture appropriée telle que rbxassetid://86896487.La texture de la chemise peut être colorée en utilisant la propriété Clothing.Color3.

Les chemises sont automatiquement chargées sur Player les caractères s'ils portent un avatar.

Échantillons de code

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

Résumé

Propriétés

Propriétés hérités de Clothing

Propriétés

ShirtTemplate

ContentId
Lecture parallèle

Le lien d'ID de contenu pointant vers le modèle de chemise hébergé sur Roblox.

Cet ID de contenu est différent de l'URL du site Web de la chemise.Il peut être trouvé en collant l'URL du site Web de la chemise dans la propriété modèle de chemise dans Studio.Alternativement, InsertService:LoadAsset() peut être utilisé pour insérer la chemise dans l'espace de travail, par exemple :


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

Voir aussi ShirtGraphic.Graphic pour l'image appliquée aux T-shirts.

Échantillons de code

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

Méthodes

Évènements