How do you make a table and what are they used for in scripting?
Tables are like variables with multiple stuff stored within them.
01 | table = { 2 , true , "Hello" } -- Tables can store these within them |
02 |
03 | while true do |
04 | print (table [ 2 ] ) -- The no. in [ ] is what you want it to print in the table. |
05 | wait( 1 ) |
06 | end |
07 |
08 | --[[ |
09 | Printed in Output = true |
10 | --]] |
11 |
12 | for 1 , 3 in pairs do |
13 | print (table [ i ] ) |
14 | wait( 1 ) |
15 | end |
Agreeing with the other answers, but you're better off with this.
Tables are used to hold things together. They usually hold values or keys. They are seperated by a comma, or a semicolon;.
1 | a = 1 --Explains A used in the table below. |
2 | b = 2 --Explains B used in the table below. |
3 | c = 3 --Explains C used in the table below. |
4 | datable = { a, b, c } --Da Table(lol). |
5 |
6 | while true do --Just an example using a table. |
7 | print ( 1 , 2 , 3 ) --Prints 1, 2, 3 used above in the table. |
8 | wait( 1 ) --Always wait 1 second before ending a infinite loop. |
9 | end |
Marked as Duplicate by BlueTaslem
This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.
Why was this question closed?