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
:
for i=1,#children do if i==7 then break end print(i, children[i].Name) children[i].Visible=true 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()
:
for i=1,#children do if children[i]:IsA("GuiObject") then --Checks if it's a GUI print(i, children[i].Name) children[i].Visible=true end end
I hope this helped!