Get category of an object

I was wondering if there is a way to get the “category” of an object. For example: textButton, textLabel, imageLabel, Frame, imageButton would fall under the category of Gui. Part, meshPart, model under building/decoration (or something like that).

1 Like

You can see the “category” of an object using the ClassName property.

1 Like

Thank you for replying, I know about this property but that gives a different result for a Part, MeshPart, Model and others. I want something more general in which different objects would be under that “category”. (if that makes sense)

1 Like


1 Like

Thanks for replying, I know about typeof but the problem with that is I can’t/don’t know how to get the type of the object to make it automatic if that makes sense. Cause for typeof() to work you need to give it the type, I want to get the type giving the object.

1 Like

I dont know if that exists in Roblox. You can try searching it or waiting, but I’m not sure that it does.

1 Like

it is class name property. or if you mean part, model, mesh union are one category then you need to make your own function.


Ok thanks, that what I thought but I hoped there is something built in.

As @HenryThe_Legendary said, you need to make your own function:

function getObjType(type1)
    if type1 == "Part" then
        print("This object is a part!")
1 Like

There is stuff like BasePart, GuiBase and ValueBase so you can check if Instance:IsA(“BasePart”). This checks for different kinds of parts like wedges and unions.

The best thing to do is make a table of categories, and check if the part’s classname is in one of these categories, and return the category, but now i am making a module. It’s gonna have a function that detect the part’s category, and return it, i am done with the 3D Interfaces.

Many objects inherit members (properties, functions and events) from abstract objects, which we call parent objects. This could be used to categorise the parts.

  • For example: All objects inherit properties from the Instance class, which makes every object an instance

  • For example: TextButtons, TextLabels, ImageLabels, Frames and ImageButtons are all subclasses of the GuiObject class.

  • For example: Parts, Unions, MeshParts, TrussParts, SpawnLocations and oddly enough – Terrain are all subclasses of the BasePart class.

They are subclasses of the abstract, parent classes because they inherit properties. You can use the IsA method which will consider the object’s most derived class (it’s ClassName) and parent classes the parent objects from which this object inherits properties from.

print( Part:IsA("BasePart") ) --> True
print( WedgePart:IsA("BasePart") ) --> True
print( Part:IsA("GuiObject") ) --> False

print( Frame:IsA("GuiObject") ) --> True
print( ImageLabel:IsA("GuiObject") ) --> True
print( Frame:IsA("BasePart") ) --> False

How do you determine what categories you care about? This is where you should consult the Classes API reference. If you look at any class’s members, you should see a heading that says Inherited from [Object] and members categorised under that are the members of the inheriting object that the subclass inherits properties from. Terrain, oddly enough, inherits members like the Anchored, CanCollide properties, etc. which makes the Terrain object a subclass of the BasePart class

1 Like

but i don’t think that,'s what he mean. he mean return the category of the instance. so like NOT DETECT the category i guess.

1 Like

category is a table, and i dont think you can return table names, so in every table, i am going to include “Name”, and return that value instead.

1 Like

The OP hasn’t declared their use case for this so I assume this is what they wanted. Either way, this is the main takeaway here:

If you wanted a table to lookup a class from, you would have to figure out a way to extract it from an API dump. It contains all classes and their members and it also contains the superclass of that class, which is the class that a specific class inherits from: