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 |
|
|
|
| 09 Aug 2017 02:59 PM |
Yes.
http://wiki.roblox.com/index.php?title=Recursion |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 09 Dec 2011 |
| Total Posts: 180 |
|
|
| 09 Aug 2017 03:03 PM |
sorry tags but yea system covered it
|
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 09 Aug 2017 03:16 PM |
| forgot the () of GetChildren on the last line but yeah |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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 |
|
|