Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can I print all properties for a part?

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

1 comment

0

Is there even a way to do this. I'm not sure it's possible

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.