Here's what I've tried:
local children = script.Parent.Parent.Parent.ItemDetails:GetChildren()
children.Visible = false
Thank you in advance for any help you may provide.
Here's what I've tried:
local children = script.Parent.Parent.Parent.ItemDetails:GetChildren()
children.Visible = false
Thank you in advance for any help you may provide.
An easy way is to set up a table of all the children, then iterate over each one, and turn it transparent, in a short clean code.
Here's an example:
local Children=Frame:GetChildren()
for i,v in pairs(Children) --Sets up loop
if v:IsA("GuiObject") then --Checks if it's a TextButton, TextLabel etc.
v.Visible=false --Sets all gui's invisible
end
end
So anyways, that's how it's done.
Now, let's try applying this to your script:
local children = script.Parent.Parent.Parent.ItemDetails:GetChildren()
for i,Child in pairs(children) do
if Child:IsA("GuiObject") then
Child.Visible=false
end
end
Now your script should work correctly.
Anyways, if you have any further problems/questions, please leave a comment below. Hope I helped :P
####-Dyler3
This can be easily accomplished with a for loop. You were close-yet you cannot directly change the table of children it provides to false. Instead, do this:
local children = script.Parent.Parent.Parent.ItemDetails:GetChildren()
for _,v in pairs(children) do
if v:IsA("Frame") then -- don't affect anything that isn't a frame, say, a script.
v.Visible = false
end
end
You could also easily put this inside a function, for example, a textbutton function. This will error unless the textbutton exists >.<
local children = script.Parent.Parent.Parent.ItemDetails:GetChildren()
script.Parent.MouseButton1Click:connect(function()
for _,v in pairs(children) do
if v:IsA("Frame") then -- don't affect anything that isn't a frame, say, a script.
v.Visible = false
end
end
end)
Hope I helped!
Lol, sorry about that. You had a good answer as well though, I'll upvote :P
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
gosh darnit, you got it 2 minutes before me! :(
you forgot the ''do'' after the pairs(Children)