Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can I print all properties for a part?

Asked by 6 years ago
Edited 6 years ago

If I have a block part, how could I print a list of it's properties? The result I want would look like:

brickcolor = whatever, color = whatever, material = whatever, reflectance = whatever

I tried the following but it doesn't work because it's an object and not a table:

local part = game.Workspace.part
for k, v in pairs(part) do 
print(k,v)
end
0
Is there even a way to do this. I'm not sure it's possible elitekiller2342 87 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

The simplest option is to put the list of properties you're interested in into a list, like so:

local properties = {"Color", "Material", "Reflectance",} --etc
local function GetPropertiesFromPart(part) -- returns a table you can use 'pairs' on
    local t = {}
    for i = 1, #properties do
        t[properties[i]] = part[properties[i]]
    end
    return t
end
local part = game.Workspace.part
for k, v in pairs(GetPropertiesFromPart(part)) do 
    print(k,v)
end

The more complicated option is to download the Roblox API dump and parse it to get the list of properties - but you probably don't need to do that.

Ad

Answer this question