How would I make a function which returns all the properties of the given instance?

I want to make a function/Bindable function which returns all the properties within the given argument, which is going to be a instance.

I’m using this code as template:

local ClassProperties do
    -- ClassProperties is a Dictionary of sorted arrays of Properties of Classes
    -- Pulls from anaminus.github.io
    -- Ignores deprecated and RobloxPluginSecurity Properties
    -- Make sure HttpService is Enabled (Roblox Studio -> Home Tab -> Game Settings -> Security -> Allow HTTP requests = "On")

    ClassProperties = {}
    local HttpService = game:GetService("HttpService")

    local Data = HttpService:JSONDecode(HttpService:GetAsync("https://anaminus.github.io/rbx/json/api/latest.json"))

    for i = 1, #Data do
        local Table = Data[i]
        local Type = Table.type

        if Type == "Class" then
            local ClassData = {}

            local Superclass = ClassProperties[Table.Superclass]

            if Superclass then
                for j = 1, #Superclass do
                    ClassData[j] = Superclass[j]
                end
            end

            ClassProperties[Table.Name] = ClassData
        elseif Type == "Property" then
            if not next(Table.tags) then
                local Class = ClassProperties[Table.Class]
                local Property = Table.Name
                local Inserted

                for j = 1, #Class do
                    if Property < Class[j] then -- Determine whether `Property` precedes `Class[j]` alphabetically
                        Inserted = true
                        table.insert(Class, j, Property)
                        break
                    end
                end

                if not Inserted then
                    table.insert(Class, Property)
                end
            end
        elseif Type == "Function" then
        elseif Type == "YieldFunction" then
        elseif Type == "Event" then
        elseif Type == "Callback" then
        elseif Type == "Enum" then
        elseif Type == "EnumItem" then
        end
    end
end

table.foreach(ClassProperties["Part"], print)

And it’s not made by me. I can’t understand almost everything in it, so, if you can explain, I would be very grateful.

Example of what I want:

local PropertiesTable = workspace.GetAllProperties:Invoke()

for _, Property in pairs(PropertiesTable) do
    print(Property)
end
1 Like

Help…?





AFAIK, you can’t print them as you can print children in folders, items in a table etc… You’d have to use Roblox’s API dumps, I’ve linked a post.

I’m actually working on a project with this function in it, but I modified it a little bit so that it allows you to print all the properties of the class you want.

local function getClassProperties()
	local ClassProperties do
		-- ClassProperties is a Dictionary of sorted arrays of Properties of Classes
		-- Pulls from anaminus.github.io
		-- Ignores deprecated and RobloxPluginSecurity Properties
		-- Make sure HttpService is Enabled (Roblox Studio -> Home Tab -> Game Settings -> Security -> Allow HTTP requests = "On")
		
		ClassProperties = {}
		local HttpService = game:GetService("HttpService")
		
		local Data = HttpService:JSONDecode(HttpService:GetAsync("https://anaminus.github.io/rbx/json/api/latest.json")) 
		for i = 1, #Data do
			local Table = Data[i]
			local Type = Table.type
			
			if Type == "Class" then
				local ClassData = {}
				
				local Superclass = ClassProperties[Table.Superclass]
				
				if Superclass then
					for j = 1, #Superclass do
						ClassData[j] = Superclass[j]
					end
				end
				
				ClassProperties[Table.Name] = ClassData
			elseif Type == "Property" then
				if (not next(Table.tags)) then
					local Class = ClassProperties[Table.Class]
					local Property = Table.Name
					local Inserted
					
					for j = 1, #Class do
						if Property < Class[j] then -- Determine whether `Property` precedes `Class[j]` alphabetically
							Inserted = true
							table.insert(Class, j, Property)
							break
						end
					end
					
					if (not Inserted) then
						table.insert(Class, Property)
					end
				end
			elseif Type == "Function" then
			elseif Type == "YieldFunction" then
			elseif Type == "Event" then
			elseif Type == "Callback" then
			elseif Type == "Enum" then
			elseif Type == "EnumItem" then
			end
		end
	end
	
	return ClassProperties
end

If you want the properties of an instance, whether it be a Part or a GuiObject (it works for everything) all you have to do is:

local partProperties = getClassProperties()["BasePart"] -- Returns a dictionary of BasePart properties

for _, property in pairs(partProperties) do
    print(property) -- Prints all the properties of BasePart
end
5 Likes