How to get a table/index internal components?

I’m trying to get a table of the Properties of an object, but I don’t think there’s an API to do that. Example below:

Part:GetProperties() --returns a table of the properties of a Part

I’m also trying to do something like this

for i,v in pairs(Enum) do
    print(v) --throws an error
end
1 Like

No method like Part:GetProperties exists, but this is doable for Enums using GetEnums and GetEnumItems:

for _,enum in pairs(Enum:GetEnums()) do
	for _,enumItem in pairs(enum:GetEnumItems()) do
		print(enumItem)
	end
end

If you elaborate on why you want to get a list of properties of an object someone might have an alternative suggestion.

2 Likes

I need to get list of properties from objects because I’m trying to create my own properties window in game and a plugin that uses a list of properties to filter out undersired/unused properties.

I remember there being an external dump in JSON showing all object’s properties. it was unofficial and would now be out of date with all the new instance types.

You could create a module that returns all valid property types for a given object by attempting to set every property on an instance within a pcall. If the pcall returns no errors, then the property exists within that instance. If it returns an error, then the property is not valid for that instance:


local properties = { -- static list of properties, you would have to manually create a list of all properties to check here. Key = Property Name, Value = Property ValueType Example. 
	ImageColor3=Color3.new();
	Size=Vector3.new(); -- you would need to handle multiple cases. Some Size properties take UDim2, some take Vector3, etc.
	TextStrokeTransparency=1;
}

local function GetValidProperties(instance)
	local valid_properties = {}
	for property, value_example in pairs(properties) do
		local success, err = pcall(function()
			instance[property] = value_example
		end)
		if success then
			valid_properties[property] = true
		end
	end
	return valid_properties
end


local valid_properties = GetValidProperties(Instance.new("Part"))
for property, is_valid in pairs(valid_properties) do
	print(property) -- prints "Size"
end

local valid_properties = GetValidProperties(Instance.new("ImageButton"))
for property, is_valid in pairs(valid_properties) do
	print(property) -- prints "ImageColor3"
end
2 Likes

If HttpService is enabled, you can interact with the JSON dump directly:

https://raw.githubusercontent.com/CloneTrooper1019/Roblox-Client-Watch/roblox/API-Dump.json

3 Likes