Pants

Pokaż przestarzałe

*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.

Przedmiot Pants wyświetla teksturę spodni z Roblox na ramieniu Humanoid.Spodnie pokrywają tułów i nogi i będą pokryte przez Shirt na tułowiu.Aby być widoczny, Pants musi być siostrą brata Humanoid i mieć ustawioną właściwość PantsTemplate na odpowiednią teksturę, taką jak rbxassetid://86896501.Tekstura spodni może być koloryzowana za pomocą właściwości Clothing.Color3.

Spodnie są automatycznie wczytywane na Player znakach, jeśli ich awatar nosi jeden.

Przykłady kodu

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

Właściwości

PantsTemplate

ContentId
Odczyt równoległy

Link ID zawartości wskazujący na szablon spodni hostowany na Roblox.

Ta identyfikator treści jest inna niż URL strony internetowej spodni.Można go znaleźć, wklejając URL strony internetowej spodni do właściwości Szablon spodni w Studio.Alternatywnie, InsertService:LoadAsset() można użyć do wstawienia spodni do przestrzeni roboczej, na przykład:


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

Dla szablonu obiektu Shirt zobacz Shirt.ShirtTemplate.

Przykłady kodu

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

Metody

Zdarzenia