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

Can you store tables in side of a table?

Asked by 5 years ago

This question has been solved by the original poster.

I want to make a head tag script, so in a table named tags I want to store more than one table, each table stores 2 strings player name and what the tag should say, a color3 value of the tag color

local tags ={
    {
        "","",Color3.fromRGB()
    }
    {
        "","",Color3.fromRGB()
    }
}

Is this possible?

1
yes User#24403 69 — 5y
0
how jackochjulius 2 — 5y
1
when listing things in a table you need to include a separator , User#5423 17 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago

This is a clear yes. Lua structures everything to be quite flexible. You can store arrays in a table. Or vice versa that you can store tables in arrays. An example is.

local tableinArray = {
    {Key="Value here!"};
    {Key="Value 2!"};
}
print(tableinArray[2].Key) --> "Value 2!"
print(tableinArray[1].key) --> "Value here!";

local arrayInTable = {
    IndexKey = {5,"Hello"};
    OtherKey = {1,5,1};
]
print(arrayInTable.IndexKey[1]) --> 5
print(arrayInTable.IndexKey[2]) --> "Hello"
print(arrayInTable["OtherKey"][3]) --> 1

Hope this helped.

Ad

Answer this question