Is there any way to distinguish an accessory from being a hat, eyewear, shoulderwear, etc?

I am trying to put a hat on a person, and by doing so I’ll need to clear out some accessories[that the player already has on] so it doesn’t look ugly. Since this is a hat I’m putting on the person, I’d intend for everything else that is not being worn on the head to be left alone(like wings, swordpacks, etc). Just how accessories are subdivided into categories in the catalog, is there a way to tell using the accessory object?

So far I’ve been looking around in the Roblox Developer API website and I’ve been looking for any sort of function or property of Accessory that would tell me what type of accessory it is. So far, there’s been no luck. Another solution is that I’d give the player the choice on whether or not he want to get rid of his current hats.

This is what I’ve been looking at so far:


You could use the Catalog API and check through that if the item is a hat, hair, etc. I can’t tell more about this API as I haven’t dove into it in the past nor am I going to do that anytime soon. Hopefully the article helps.

Another way would be looking at this thread as it’s an similar issue and is handled differently by checking attachments


Unfortunately, it isn’t possible to distinguish a hat from a wing in the Accessories class using an external source.

My hacky solution is to simply GetTouchingParts() and remove them, while ignoring the body parts. It is a little hacky, but it works.

This question has already been asked and answered:

1 Like

There isn’t any way to get the id of the accessories provided in any person’s custom characters. You just have the Accessory object and the Handle.(not very useful to me). I was wondering if you could take an Accessory object and get its ProductInfo. I think this would be a good feature imo.

Also the mesh and texture Id’s don’t work either

1 Like

This seems like a perfect use case for the HumanoidDescription system, however, from what I can see, accessories are represented as just a single string property per type (back, head, face, etc.). This isn’t ideal as players can wear more than one accessory of the same type at once.

I’m not sure why this was implemented in such a way, but it seems like an oversight. I’ll file a feature request to add a method to get all accessories and their IDs soon.


Turns out that the accessory properties do describe every single accessory ID of that type, not just one, so humanoid descriptions can be used for this problem.

1 Like

I mean you could just use the weld created in the accessory to determine the location. I noticed this specifically when I was adding an accessory to my pathfinder NPC. You couldn’t really determine the difference between a front and back accessory (as that’s not really how they role when you come to programming them) however you could determine what section of the body they are connected to and thus you can get a realistic guess to some degree.

I’d have to see what data we are given to use in order to determine if you could refine this though as with some hats you could (if the handle permits it) work out the position relative to the players head and again make a guess - sadly we have no direct way of working it out though.

Good luck :slightly_smiling_face:

check the attachment name in the accessory handle
e.g.: hair accessories will have “HairAttachment” in their handles


Studio is a game engine, all it needs to know is the mesh, texture and position of the object which are stored as IDs. It likely wasn’t implemented originally for specific data such as the type of accessory purely because it wouldn’t be relevant to the engine and was essentially redundant data which would only slow down the process.

You can get all accessories by doing a simple :GetChildren() and recurring it, then ask it to store the Ids it finds in a table and output them at the end - but you can make custom accessories with your own meshes and textures so you’d have the fun issue of differentiating if an accessory is created by the player or by Roblox because doing (this is a fake function) :GetAccessoriesWithData() would return an error for anything that isn’t a Roblox mesh / accessory.

What would be nicer is if they had built in services which allowed you to get the information of the specific hat and all the data you may want (such as where the hat is sat on the player). I recently asked for them to allow you to remove a specific instance / object in table.remove() purely because it’s much smoother :joy:

Why would you want the accessory information on an existing accessory though if it’s pre-provided and the accessory is there :thinking:

Something like this is already implemented, though. Getting the asset IDs of Roblox accessories on the character is already possible to an extent with the HumanoidDescription system. Using the HumanoidDescription.HatAccessory property, for example, provides you with the asset ID of any Roblox hats the player is wearing. The problem (according to my assumptions based on the data type of the property) was that the accessory properties only provided one ID, even when there were more than one of the same Roblox accessory type on a humanoid.

However, after further inspection, it appears I was wrong about this: the properties are described as a string with each accessory ID separated by a comma. This allows you to get the accessory type of every Roblox accessory on a humanoid without even using MarketplaceService like the solution to the other thread did. Simply go through each accessory property of the humanoid’s description and store the ID with the accessory type (which can be derived simply from which property you’re using).

For @laughablehaha’s case it is not necessarily to get the type of any accessories anyway. Simple set the HumanoidDescription.HatAccessory of every humanoid to an empty string:

local humanoid = character.Humanoid
local description = humanoid:GetAppliedDescription()
description.HatAccessory = ""

This should be done on the server.


… Wow. This works a lot better than my previous method. I used :GetTouchingParts() on the head (to remove hats only) which removed everything on the head including eyewear and other non-head accessories that unluckily made contact with the head. Yes, humanoid description is a lot smoother and my solution was solved with many less lines of code.

Also you have a slight typo with Accessory in your example code. You said “Accesory”