generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Hierarchical GetChildren Script Not Working

Previous Thread :: Next Thread 
Pika_Bolt is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image