Creating a 3D array with code, how do I do it?
Hi everyone,
I know how I would set this out if I could set the data structure out beforehand, by doing:
1 | local array = { foldername = { child, child } ; foldername = { child, child } } |
But how do I do this when I just can't foresee how many folders (or any other object for that matter) and need a variable amount of secondary arrays?
I tried this, but it errors.
03 | for i, v in pairs (sp:GetChildren()) do |
04 | if v:IsA( "Folder" ) then |
05 | table.insert(array, v) |
06 | for _, x in pairs (v:GetChildren()) do |
07 | table.insert(array [ i ] , x.Name) |
My output:
14:30:01.904 - Workspace.Script:5: bad argument #1 to 'insert' (table expected, got Object)
14:30:01.905 - Script 'Workspace.Script', Line 5
14:30:01.906 - Stack End