Change "Visible" using tables not working

Hello! I’m trying to set the visibility of a bunch of GUI’s usign tables, but for some reason they are not chaning… (There’s no erros on output)
script:

local mainMenu = {

script.Parent.Parent.Credits,

script.Parent.Parent.Donate,

script.Parent.Parent.Play,

script.Parent.Parent.Parent.GameTitle

}

--

local credits = {

script.Parent.Parent.Parent.Menus.CreditsMenu.CreditsMenu,

script.Parent.Parent.Parent.Menus.CreditsMenu.CreditsMenu.Back

}

--

local donate = {

script.Parent.Parent.Parent.Menus.DonateMenu.Donate100,

script.Parent.Parent.Parent.Menus.DonateMenu.Donate10,

script.Parent.Parent.Parent.Menus.DonateMenu.Donate50,

script.Parent.Parent.Parent.Menus.DonateMenu.Donate500,

script.Parent.Parent.Parent.Menus.DonateMenu.Advice,

script.Parent.Parent.Parent.Menus.DonateMenu.Title

}

local play = {

script.Parent.Parent.Parent.Menus.PlayMenu.Back,

script.Parent.Parent.Parent.Menus.PlayMenu.ENGLISH,

script.Parent.Parent.Parent.Menus.PlayMenu.PORTUGUESE,

script.Parent.Parent.Parent.Menus.PlayMenu.Title

}

function mouseClick()

effect:Play()

wait(0.1)

TweenService:Create(

fade,

TweenInfo.new(1),

{BackgroundTransparency = 0}

):Play()

wait(1)

mainMenu.Visible = false

play.Visible = true

wait(1)

TweenService:Create(

fade,

TweenInfo.new(1),

{BackgroundTransparency = 1}

):Play()

end

script.Parent.MouseButton1Click:Connect(mouseClick)

The items:
image

You need to loop through the table if you are trying to do something with it. You can do it like this:

for i, v in pairs(mainMenu) do -- Change mainMenu to the name of the table
   -- insert your code here
   v.Visible = false
end

Please mark this as “Solution” if it helped you out. Thanks!

Thank you very much! It was very helpful.

1 Like