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

How to Set Properties from a table?

Asked by 6 years ago

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

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago
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
0
What about Parents. If the Parent's don't exist at startup it doesn't work. MariusCorpelius 0 — 6y
Ad

Answer this question