Pants

Mostrar obsoleto

*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.

El objeto Pants muestra una textura de pantalones de Roblox en un rig Humanoid .Los pantalones cubren el torso y las piernas, y se cubrirán con un Shirt en el torso.Para ser visible, un Pants debe ser un hermano de un Humanoid y tener su propiedad PantsTemplate establecida a una textura apropiada como rbxassetid://86896501.La textura de los pantalones puede ser coloreada usando la propiedad Clothing.Color3.

Los pantalones se cargan automáticamente en Player caracteres si su avatar lleva uno.

Muestras 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.

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

Resumen

Propiedades

Propiedades heredados de Clothing

Propiedades

PantsTemplate

ContentId
Leer paralelo

El enlace de ID de contenido que apunta a la plantilla de pantalones alojada en Roblox.

Este ID de contenido es diferente de la URL del sitio web de los pantalones.Se puede encontrar pegando la URL del sitio web de los pantalones en la propiedad PantsTemplate en Studio.Alternativamente, InsertService:LoadAsset() se puede usar para insertar los pantalones en el espacio de trabajo, por ejemplo:


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

Para el modelo de un objeto Shirt, vea Shirt.ShirtTemplate.

Muestras 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.

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étodos

Eventos