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

Issue regarding tables

Asked by 10 years ago

I am having an issue regarding tables. I have a table like:

local Table = { Part1 = {true, false}, Part2 = {false, false}}
print(#Table)

It prints 0, any way I can fix that, do I need to just make them tables without the "PartX"'s?

1 answer

Log in to vote
2
Answered by 10 years ago

The #table syntax only works on tables with numerical keys. You don't need to assign a key to those values, since they are redundant.

Just make them numerical keys, like so:

Parts = {
    {true, false},
    {false, false}
}
print(#Parts)
-->> 2
0
Ok, thanks. I just used the "Part1 =" thing for other people to easily edit. :P FromLegoUniverse 264 — 10y
0
You can put Part1/Whatever in each table for identification purposes. Azarth 3141 — 10y
Ad

Answer this question