Pants
*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.
L'oggetto Pants mostra una texture di pantaloni da Roblox su un Piattaforma di testHumanoid .I pantaloni coprono il torso e le gambe e saranno coperti da un Shirt sul torso.Per essere visibile, un Pants deve essere un fratello di un Humanoid e avere la sua proprietà PantsTemplate impostata su una texture appropriata come rbxassetid://86896501.La texture dei pantaloni può essere colorata utilizzando la ProprietàClothing.Color3.
I pantaloni vengono caricati automaticamente su Player caratteri se il loro avatar indossa uno.
Campioni di codice
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
Sommario
Proprietà
Determina la texture del Pants .
Determina la colorazione da applicare alla StrutturaClothing .
Metodi
Proprietà
PantsTemplate
Il link dell'ID del contenuto che punta al modello di pantaloni ospitato su Roblox.
Questo ID contenuto è diverso dall'URL del sito web dei pantaloni.Può essere trovato incollando l'URL del sito web dei pantaloni nella proprietà PantsTemplate in Studio.In alternativa, InsertService:LoadAsset() può essere utilizzato per inserire i pantaloni nell'area di lavoro, ad esempio:
local InsertService = game:GetService("InsertService")
local Workspace = game:GetService("Workspace")
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 InsertService:LoadAsset(assetId)
end)
if success then
model.Parent = Workspace
end
Per il modello di un oggetto Shirt , vedi Shirt.ShirtTemplate .
Campioni di codice
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