Getting the child classes of a class

Hi, I am having trouble getting the child classes of a class. When I think about it that sounds complex. Let me show you!

Currently my script looks like this.

local Classes = require(script.Classes)


for ClassName: string, Properties: {string} in Classes do
	local Object = -- ERROR: Unable to create an Instance of type "BasePart"
	for _, Property: string in Properties do
		local Value = Object[Property]
		if (Value == nil) then continue end

The Classes variable is just a table of alot of classes, like BasePart, Part, all of the classes are in there. It looks something like this:

    BasePart = {ALOT OF PROPERTIES};
    ImageLabel = {PROPERTIES};
    blahblah = {PROPERTIES};

Let me get to the point, my script loops through all the classes in the table and then loops through the properties in that Class. E.g BasePart has properties like Anchored, CanCollide, CanQuery, Transparency, and so on. And when it loops through, it also checks what DataType that property is. I need to know if the property type is a boolean or Vector3 or number and all the other ones.

But the problem here is when I create a reference object from the ClassName it doesn’t like the BasePart ClassName since that is not a valid Instance that one can create with the function. Its just a parent class that is there for inheritance. So I need to get a child class within the BasePart class, an example of this is a Part. But I don’t know how to get the child classes.

Would appreciate any help! :+1:

1 Like

couldnt you have 1 of all creatable instances and call :IsA('BaseClass') on it to see if that instances main class is a “child” class of the base class?

1 Like

That is a good idea, didn’t think of that. Ill try it!