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

What do the Brackets do for this little script?

Asked by 4 years ago

What do the Brackets [] do on the 3rd line after the table name?

local table = {1, "Hello", false}

print(table[math.random(#table)])

2 answers

Log in to vote
0
Answered by 4 years ago

SO here's an example of brackets being used:

local table = {1, "Hello", false}

print(table[1]) --//Will print 1

If you change the first thing in the table to whatever, it'll print whatever the first thing in the in the table is. The brackets are used to insert which part of the table you want

Here's another example:

local table = {"Wassup", "Hello", false}

print(table[1]) --//Prints wassup

Hope this helps!

Ad
Log in to vote
-2
Answered by 4 years ago

I think that basically prints the table.

Answer this question