Shirt 對象會顯示來自 Roblo屬性 的
如果有人穿上了頭盔,則會自動載入 Player 角色。
範例程式碼
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
屬性
ShirtTemplate
ContentId
指向 Roblox 上的服裝樣板的內容 ID 連結。
此內容ID與服裝網站的網頁URL不同。它可以通過將服裝網站的網頁URL貼入 Studio 中的 服裝樣板 屬性來找到。或者,InsertService:LoadAsset() 可以用來將服裝樣板插入工作區,例如:
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 game:GetService("InsertService"):LoadAsset(assetId)
end)
if success then
model.Parent = workspace
end
也參閱 ShirtGraphic.Graphic 對於 T 恤的圖像。
範例程式碼
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
屬性 繼承自 Clothing