"Linking" Accessories with its Id

So, uh. I doubt it’s possible, but I think it could be worth reaching out, since I can’t find anything that specifically aligns with my needs.

So basically, in basic terms:

In the character you have Accessories, yes?
as well as that you have the Humanoid, with HumanoidDescription.
this contains the Id that solves all my problems.
I’ve figured out how to link that Id to find the actual name, for example:

13540902329 being a “Faceless” item on the Catalog.

This is kinda USELESS right now.
as you may already know, some accessories don’t actually align with what it is, it can be just… Accessory (MeshAccessory) or whatevs.

Now, if possible, is there any way at all, AT ALL to link Accessories, like IS THERE ANY WAY AT ALL TO DO THIS, doesn’t have to be the humanoid description thingy, to the marketplace, and renaming said accessory inside the character to match up with its marketplace name?

if not, that’s alright! it’s just… a minor inconvenience, i guess.

(I’m sorry if I can’t give much context currently, I’m in a little rush)

I believe this is what you’re looking for:

funny thing, i literally JUST found something that is similar to what i needed, literally shortly after i posted this.

so… yeah. honest mistake, i guess. thanks for your help anyways!

1 Like

I know you’ve already marked this as solved, but this is another way to achieve what you want without loading the accessories again with InsertService.

local function GetNameFromAssetId(CharacterAppearanceInfo:{}, AccessoryAssetId:number):string
	for _,AccessoryDetails in pairs(CharacterAppearanceInfo.assets) do
		if AccessoryDetails.id == AccessoryAssetId then
			return AccessoryDetails.name
		end
	end
	
	warn(`Unable to find accessory name for AssetId:{AccessoryAssetId} with provided CharacterAppearanceInfo`)
end

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Humanoid:Humanoid = Character.Humanoid
		local HumanoidDescription:HumanoidDescription = Humanoid.HumanoidDescription

		local AccessoryInfo = HumanoidDescription:GetAccessories(true)
		local AppearanceInfo = game.Players:GetCharacterAppearanceInfoAsync(Player.UserId)
		local WornAccessories:{Accessory} = Humanoid:GetAccessories()
		
		for AccessoryIndex, AccessoryInstance in ipairs(WornAccessories) do
			local CurrentAccessoryId = AccessoryInfo[AccessoryIndex].AssetId
			local MarketplaceName = GetNameFromAssetId(AppearanceInfo,CurrentAccessoryId)

			AccessoryInstance.Name = MarketplaceName or AccessoryInstance.Name
		end
	end)
end)
3 Likes

Does Roblox document the fact that Humanoid:GetAccessories() returns the accessories in a specific order that happens to line up with the array returned by HumanoidDescription:GetAccessories() anywhere?

I typically expect functions like GetChildren() to return their content in an unreliable order so the fact that they line up like this is surprising to me.

I don’t believe that it’s documented anywhere, but from what I can tell, when the HumanoidDescription for a player is created, the properties for it are added in the same order that GetCharacterAppearanceInfoAsync() returns.

If you print the index of the loop in GetNameFromAssetId() when the AssetId’s match, the index is always higher than the index of any previous accessory match for that character.

As for why the two GetAccessories() arrays both match in order, I assume that the accessories are applied to the character in the order that HumanoidDescription:GetAccessories() returns, which would also add it to the Humanoid’s array in that same order.

2 Likes

I don’t know how you even figured something like that out, but it’s a help to me haha.