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: Finding All Children (Despite how deep)?

Previous Thread :: Next Thread 
ClanDrone is not online. ClanDrone
Joined: 12 Feb 2013
Total Posts: 61
09 Aug 2017 02:56 PM
for _, child in pairs(Workspace:GetChildren()) do
if child.Name == "PreviousButton" then
child.ZIndex = 2
end
end

The purpose of this script is simply to change all the GUI TextButtons to a ZIndex of 2. The "PreviousButton"s are deep many layers of models and GUIs. Is there a way that the script can search for all of them and bypass the irregular layers of models and GUI frames?
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
09 Aug 2017 02:59 PM
Yes.

http://wiki.roblox.com/index.php?title=Recursion
Report Abuse
tanmanny9 is not online. tanmanny9
Joined: 09 Dec 2011
Total Posts: 180
09 Aug 2017 03:01 PM
use a function that calls the next children function PlaceHolder(v) for _, child in pairs(v) do if child.Name == "PreviousButton" then if(v:GetChildren())then PlaceHolder(v) end child.ZIndex = # ### ####### ####################################
Report Abuse
tanmanny9 is not online. tanmanny9
Joined: 09 Dec 2011
Total Posts: 180
09 Aug 2017 03:03 PM
sorry tags but yea system covered it


Report Abuse
ClanDrone is not online. ClanDrone
Joined: 12 Feb 2013
Total Posts: 61
09 Aug 2017 03:11 PM
function colorAllParts(object, zindex)
if object:IsA("PreviousButton") then
object.ZIndex = zindex
end
for _, child in ipairs(object:GetChildren()) do
colorAllParts(child, zindex)
end
end
colorAllParts(game.Workspace, ZIndex.2)

So something like this? (Didn't change colorAllParts, so I don't mess things up)
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
09 Aug 2017 03:15 PM
function changeZIndex(object, ZIndex)
if object.Name == "PreviousButton" then
object.ZIndex = ZIndex
end
for _, child in ipairs(object:GetChildren()) do
changeZIndex(child, ZIndex)
end
end
changeZIndex(workspace:GetChildren, 2)
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
09 Aug 2017 03:16 PM
forgot the () of GetChildren on the last line but yeah
Report Abuse
ClanDrone is not online. ClanDrone
Joined: 12 Feb 2013
Total Posts: 61
09 Aug 2017 03:21 PM
(Error in script: function arguments expected near ',') From the output.
Does that mean I need to better define the ZIndex in the function, like what its looking for?

By the way, thank you so much for helping me out.
Report Abuse
vastqud is not online. vastqud
Joined: 10 Sep 2011
Total Posts: 2464
09 Aug 2017 03:22 PM
when you call the function, do this:

changeZIndex(workspace, 2)

instead of this:

changeZIndex(workspace:GetChildren, 2)


Report Abuse
ClanDrone is not online. ClanDrone
Joined: 12 Feb 2013
Total Posts: 61
09 Aug 2017 03:23 PM
Oops :P I'm stupid. Thanks for helping. I'm going to practice more recursion
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