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

Anyway to print out every element of a table?

Asked by 9 years ago

Anyway to print out every element of a table? Thanks

2 answers

Log in to vote
0
Answered by
funyun 958 Moderation Voter
9 years ago

Yes, and that is with pairs().

http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#pairs

t = {a = 1, b = 2, c = 3}

for i, v in pairs(t) do
    print(i..": "..v)
end
1
Actually the pairs is a function, it's the for that is a loop. woodengop 1134 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

You can use the table.concat()inside the print. Don't have to use the forloop. table.concat() page

print(table.concat(NameOfYourTable, ", "))

Output>>elements, in, your, table

Answer this question