How do you make a table and what are they used for in scripting?
Tables are like variables with multiple stuff stored within them.
table = {2,true,"Hello"} -- Tables can store these within them while true do print(table[2]) -- The no. in [ ] is what you want it to print in the table. wait(1) end --[[ Printed in Output = true --]] for 1 , 3 in pairs do print(table[i]) wait(1) end --[[ Printed in Output = 2 = true = Hello Printed one after the other as i = 1 and v = 3 so it does it 3 times, one after the other. --]]
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;.
a = 1 --Explains A used in the table below. b = 2 --Explains B used in the table below. c = 3 --Explains C used in the table below. datable = {a, b, c} --Da Table(lol). while true do --Just an example using a table. print(1, 2, 3) --Prints 1, 2, 3 used above in the table. wait(1) --Always wait 1 second before ending a infinite loop. 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?