Best method of getting the template ID of clothing?

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.

10 Likes

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.

12 Likes

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

10 Likes

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.

4 Likes

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. :huh:

EDIT: This leads me to believe there isn’t an easy/direct/normal way to do this.

5 Likes

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.

2 Likes

Honestly I’m not sure if there is another method other than the super tedious way of going through them one by one

2 Likes

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 GeorgeTheDev thumbnails, but clearly that is not what we’re doing. We’re attempting to use clothing.

1 Like

Here’s a link to an article explaining how to do it:
https://developer.roblox.com/en-us/api-reference/property/Shirt/ShirtTemplate

But for people who just want to read I’ll give a quick break down:

  1. Get the asset id from the catalog URL
  2. Use game:GetService("InsertService"):LoadAsset(assetIdHere) to load a model of the shirt into the game
  3. 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
13 Likes
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

2 Likes