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

How to Set Properties from a table?

So Lets Say I'm making a table that will allow me to code in things at runtime. It would look like this:

local guiobjects =
{
	{
		["ClassName"] = "Frame";
		["Parent"] = game.StarterGui;
	};
};

How would I go about creating the instance and setting the Properties?

1 answer

for _,gui in pairs(guiobjects) do
	local newGui = Instance.new(gui.ClassName)
	for i,v in pairs(gui) do
		if i ~= "ClassName" then
			newGui[i] = v
		end
	end
end

1 comment

0

What about Parents. If the Parent's don't exist at startup it doesn't work.

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