Pika_Bolt
|
  |
| Joined: 21 Nov 2011 |
| Total Posts: 156 |
|
|
| 20 Mar 2016 11:22 PM |
Hello, I'm trying to make a script in which a table with every single part and their children are added into a table, hierarchically. For example, if this script was executed towards a Model with two parts, with three scripts in each part, and a Random Object in each Second Script, this is what the result should be, if the table was to be printed:
1 Part 1 1.1 Script 1 of Part 1 1.2 Script 2 of Part 1 1.2.1. Random Object of Script 2 of Part 1 1.3 Script 3 of Part 1 2 Part 1 2.1 Script 1 of Part 1 2.2 Script 2 of Part 1 2.2.1. Random Object of Script 2 of Part 2 2.3 Script 3 of Part 1
Unfortunately, it is not working, so if you could assist me in making this function, I'd greatly appreciate it.
InstanceArray = {} function GetChildren(Instance,Prefix) local children = workspace:GetChildren() for index = 1, #children do local child = children[index] InstanceArray[Prefix.."."..index] = child if child:GetChildren()[1] ~= nil then GetChildren(child,index) end end end GetChildren(game,"") Thanks, Pika_Bolt (formerly Pikachu84639) • The answer to a math question is the question itself. Proof: 9+10 = 9+10 - Correct ✔ |
|
|
| Report Abuse |
|
Pika_Bolt
|
  |
| Joined: 21 Nov 2011 |
| Total Posts: 156 |
|
|
| 20 Mar 2016 11:41 PM |
B.U.M.P.
Pika_Bolt (formerly Pikachu84639) • The answer to a math question is the question itself. Proof: 9+10 = 9+10 - Correct ✔ |
|
|
| Report Abuse |
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 21 Mar 2016 12:03 AM |
| Instead of 'Workspace:GetChildren()' try 'Instance:GetChildren()' and set at the bottom 'GetChildren(game.Workspace, "") |
|
|
| Report Abuse |
|