Answered by
5 years ago Edited 5 years ago
Use the unary length operator, #.
This is all you need. The unary length operator gets how many elements are in a table.
So don't unpack it, you can instead just get the length:
However this won't print 1 2
, it will just print 2
. If you really want to print the former, you can insert the index instead of the child reference:
1 | for pos, child in ipairs (workspace.Servers:GetChildren()) do |
2 | if child:IsA( "Folder" ) then |
3 | table.insert(instances, pos) |
And you can unpack it
1 | print (table. unpack (instances)) |