Yeah so I get the children of a GUI and then use a for loop to check the children yet its telling me it cant because its a number value? Since when does :GetChildren() return a number?
local but = script.Parent local site = script.Web.Value local ser = but.Parent.SerBar local url = script.URL but.MouseButton1Click:connect(function(plr) local gui = but.Parent:FindFirstChild(site):GetChildren() local all = but.Parent:GetChildren() for v = 1 , #all do if v.ClassName == "Folder" then local gc = v:GetChildren() for e = 1, #gc do e.Visible = false end end end ser.Text = url.Value for i = 1, #gui do i.Visible = true end end)
This is the Error
Players.CrispyBrix.PlayerGui.SurfaceGui.WHITE.Home.Click:10: attempt to index local 'v' (a number value)
Any help is appreciated
This is not how you use a numerical loop to access an array. You are using the number in the loop as opposed to using the number to access the element in the array.
Example.
local tbl = {'a', 'b', 'c'} for i=1, #tbl do print(tbl[i]) end
You should have also read the error which explains the issue in your code as looping through tables is a basic part of programming.
Try this
local but = script.Parent local site = script.Web.Value local ser = but.Parent.SerBar local url = script.URL but.MouseButton1Click:connect(function(plr) local gui = but.Parent:FindFirstChild(site):GetChildren() local all = but.Parent:GetChildren() for i,v in pairs(all) do if v.ClassName == "Folder" then local gc = v:GetChildren() for u,f in pairs(gc) do f.Visible = false end end end ser.Text = url.Value for i,v in pairs(gui) do v.Visible = true end end)