Get Hats the Player Has Equipped via Their Roblox Avatar and How Many

You know how in-game avatar editors have bubbles that show which items are equipped? In my game, currently, it shows the items equipped in the in game avatar editor. How do I get the items the player has on via their Roblox avatar? Hats to be specific. Just the ids of the hats they have and how many hats they have cuz in my game the limit is 3

This looks like what you’d need:

https://developer.roblox.com/en-us/api-reference/function/Players/GetCharacterAppearanceInfoAsync

You could iterate over the assets table to see everything that they’re wearing.

local function getHatCount()
local hatCount = 0

for _, asset in pairs(game.Players:GetCharacterAppearanceInfoAsync(game.Players.LocalPlayer.UserId).assets) do
if asset.assetType.name == "Hat" then
hatCount += 1
end
end

end
2 Likes

How would I name the hats Hat1, Hat2, and Hat3, doesn’t have to be in order

What are you trying to do exactly??

1 Like

It like 300+ lines of code but basically what I’m stuck on is making it so when they join for the first time it checks the hats they have, changes the hat amount value so the in-game avatar editor can’t equip over the limit and then loads in their hats as bubbles so they can click them to remove them. I have most of it working

1 Like

You will just have to add simple values for it.

1 Like