This was the example for printing the names of all children of an object:
local children = Workspace:GetChildren() for i = 1, #children do print(i, children[i].Name) end
So i changed it to make my GUI become visible, without the locals and stuff:
for i = 1, #children do print(i, children[i].Name) children[i].Visible = true end
However, my 8th child is a Script, so it fails and doesn't continue the script since it can't become visible,
How do i make it stop before hitting the 8th Child?
To stop at a certain child, you would use an if
statement and break
:
1 | for i = 1 ,#children do |
2 | if i = = 7 then |
3 | break |
4 | end |
5 | print (i, children [ i ] .Name) |
6 | children [ i ] .Visible = true |
7 | end |
However, this is more of a hard-coded single-use method. It's better to check if the item is a GUI element with :IsA()
:
1 | for i = 1 ,#children do |
2 | if children [ i ] :IsA( "GuiObject" ) then --Checks if it's a GUI |
3 | print (i, children [ i ] .Name) |
4 | children [ i ] .Visible = true |
5 | end |
6 | end |
I hope this helped!