What's the best way to get an accessory type?

So accessories are split into various categories: Back, Face, Front, etc…

What’s the best way to find out what type an accessory is is from its CatalogID?

For example:

local accessoryId = 106690045
local accessoryType = "???"
local desc = humanoid:GetAppliedDescription()
desc[accessoryType] = accessoryId
humanoid:ApplyDescription(desc)
3 Likes

MarketplaceService:GetProductInfo returns a table of information about the item with the given ID. One of the keys of this table is "AssetTypeId", which is assigned to a number that identifies the asset type of the item. The number given follows this article on asset types:

local marketplaceService = game:GetService("MarketplaceService")
local accessoryTypes = {
    [8] = "HatAccessory",
    [41] = "HairAccessory",
    [42] = "FaceAccessory",
    [43] = "NeckAccessory",
    [44] = "ShouldersAccessory",
    [45] = "FrontAccessory",
    [46] = "BackAccessory",
    [47] = "WaistAccessory",
}

local accessoryId = 106690045
local info = marketplaceService:GetProductInfo(106690045)
local accessoryType = accessoryTypes[info.AssetTypeId]
local desc = humanoid:GetAppliedDescription()
desc[accessoryType] = accessoryId
humanoid:ApplyDescription(desc)
12 Likes

You can build a list using

local lst = {}
for i, v in pairs(Enum.AssetType:GetEnumItems()) do
lst[v.Value] = v.Name
end

2 Likes

This wouldn’t work. The EnumItem names differ from the asset type identifiers.

Forgot to use v.Value XD but it should work. The names will be the same.

Or using

local tbl = {
[Enum.AssetType.HairAccessory.Value] = Enum.AssetType.HairAccessory.Name, 
...
}

Ah, I was looking at the article rather than the API reference page. Still, the Enum’s “ShoulderAccessory” differs from HumanoidDescription’s “ShouldersAccessory” (which it shouldn’t). Other than that, I believe this should work.

1 Like

I am not sure if that “ShouldersAccessory” should have been “ShoulderAccessory”.

File a Feature Request to have this rectified. It was most likely an unintentional typo.

No need I have passed this on.

1 Like