I have tried the subtracting one from the ID and comparing the creator IDs of both items until they match, but this method does not work for group items as the template and asset have different creator IDs.
Iām pretty sure that Roblox Studio converts the ID automatically - so just take the shirt link and put it into the āShirtTemplateā section of a shirt. From there you could parse it or do whatever you need to do.
Iām not sure if thereās a more direct way though.
If you are doing this manually it can very easily be done by putting a decal onto a brick in studio and then copying the clothing asset into the texture field on the decal, which then gives you back the image asset id. It might be possible to do this with a script, but i havenāt tried it
This wonāt work since I am not doing this manually in studio, but instead, players are allowed to put clothing IDs on mannequins in game and then sell them there.
Ah darn. Iām gonna keep looking into this because this is annoying the heck out of me. Studio does convert it somehow from a shirt to an image, but you have to press enter for it to convert.
EDIT: This leads me to believe there isnāt an easy/direct/normal way to do this.
Iāve been trying to find a fix all day for this issue, but itās quite frustrating as Roblox does not seem to offer any way to get the template id.
Honestly Iām not sure if there is another method other than the super tedious way of going through them one by one
Was a solution ever found for this?
I am attempting to do this exact same thing. This points to Convert Decal asset id to Image asset id - #2 by GeorgeOfAIITrades thumbnails, but clearly that is not what weāre doing. Weāre attempting to use clothing.
Hereās a link to an article explaining how to do it:
But for people who just want to read Iāll give a quick break down:
- Get the asset id from the catalog URL
- Use
game:GetService("InsertService"):LoadAsset(assetIdHere)
to load a model of the shirt into the game - Parent the shirt from the newly created model into the playerās character, or simply extract the id from the shirt in the model and edit the one on the playerās character to match it
local marketplace = game:GetService"MarketplaceService"
local getProductInfo = marketplace.GetProductInfo
local assetTypeIds = {2, 11, 12, 13} --T-Shirt, Shirt, Pants, Decal.
local maxTries = 5 --Maximum retries per catalog ID.
local maxDepth = 100 --Maximum depth to search for.
local function getAssetIdFromCatalogId(catalogId : number) : number
local success, result = pcall(getProductInfo, marketplace, catalogId)
if success then
if result then
if table.find(assetTypeIds, result.AssetTypeId) or (result.AssetTypeId == 21 and catalogId <= 2124343749) then --Badges with an ID below 2124343749 (before they were given their own URL directory).
local cache, success2, result2 = table.create(100), nil, nil
repeat
task.wait()
catalogId -= 1
if result.AssetId - catalogId > maxDepth then
return
end
if cache[catalogId] then
cache[catalogId] += 1
else
cache[catalogId] = 1
end
if cache[catalogId] > maxTries then
continue
end
success2, result2 = pcall(getProductInfo, marketplace, catalogId)
if not success2 then
warn(result2)
catalogId += 1
end
until result2 and result2.Creator.CreatorType == result.Creator.CreatorType and result2.Creator.CreatorTargetId == result.Creator.CreatorTargetId
return result2.AssetId
end
end
else
warn(result)
end
end
local assetId = getAssetIdFromCatalogId(14417332)
print(assetId) --14417331
Hereās an implentation which works for all asset types where this behavior is observed (decals, t-shirts, shirts, pants & badges).
The following badge was used for testing purposes.
https://www.roblox.com/badges/14417332/John-Loved-of-Muses
For anyone still needing this, hereās an experience I made a while back.
This is the code for it:
function getId(assetId)
local success, model = pcall(function()
return InsertService:LoadAsset(assetId)
end)
if success then
model.Parent = workspace
local clothing = model:FindFirstChildWhichIsA("Clothing")
if clothing:IsA("Pants") then
return clothing.PantsTemplate
elseif clothing:IsA("Shirt") then
return clothing.ShirtTemplate
else
error("Unexpected type of asset")
end
else
error("Request for " .. tostring(assetId) .. " failed: " .. tostring(model))
end
end
local game = game
local insertService = game:GetService("InsertService")
local loadAsset = insertService.LoadAsset
local classToPropertyMap = {["Shirt"] = "ShirtTemplate", ["Pants"] = "PantsTemplate", ["ShirtGraphic"] = "Graphic"}
local function getAssetIdFromCatalogId(catalogId)
local success, result = pcall(loadAsset, insertService, catalogId)
if success then
for className, propertyName in pairs(classToPropertyMap) do
local clothing = result:FindFindFirstChildOfClass(className)
if clothing then return clothing[propertyName] end
end
else
warn(result)
end
end
local tShirtAssetId = getAssetIdFromCatalogId(1028595) --bloxxer
print(tShirtAssetId) --1028594
local shirtAssetId = getAssetIdFromCatalogId(607785314) --roblox jacket
print(shirtAssetId) --607785311
local pantsAssetId = getAssetIdFromCatalogId(129459077) --black slacks
print(pantsAssetId) --129459076
Added t-shirts.
Thank you! I updated the experience to support this. By the way, your code is slightly wrong, the ShirtGraphic is called āShirt Graphicā, not āClothingā. I fixed this by using
local clothing = (model:GetChildren())[1]
*It works properly in the experience.
My edit didnāt go through before.