Pants
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
วัตถุ Pants แสดงเทกเจอร์กางเกงจาก Roblox บนแรม Humanoidกางเกงครอบตัวและขา และจะได้รับการครอบคลุมโดย Shirt บนลําตัวเพื่อให้มองเห็นได้ ต้องมี Pants เป็นพี่น้องของ Humanoid และมีค่า PantsTemplate ของมันถูกตั้งค่าเป็นเทกเจอร์ที่เหมาะสมเช่น rbxassetid://86896501เนื้อผ้ากางเกงอาจถูกสีได้โดยใช้คุณสมบัติ Clothing.Color3
กางเกงจะโหลดอัตโนมัติบนตัวละคร Player ถ้าอวตารของพวกเขาสวมใส่อยู่
ตัวอย่างโค้ด
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
สรุป
คุณสมบัติ
PantsTemplate
ลิงค์รหัสเนื้อหาที่ชี้ไปที่แบบจำลองกางเกงที่โฮสต์บน Roblox
ID เนื้อหานี้แตกต่างจาก URL เว็บไซต์ของกางเกงสามารถค้นหาได้โดยการวางที่อยู่เว็บไซต์ของกางเกงลงในคุณสมบัติ PantsTemplate ใน Studioหรือสามารถใช้ InsertService:LoadAsset() เพื่อใส่กางเกงลงในพื้นที่ทำงานได้ เช่น:
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
สำหรับเทมเพลตของวัตถุ Shirt ดูที่ Shirt.ShirtTemplate
ตัวอย่างโค้ด
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