Can't solve a Syntax related to GUI

I’m trying to make a system that goes through every GUI element in a folder and makes them invisible, unfortunately i have run into some trouble, i keep getting the same syntax and i have no idea whats wrong with it.

Syntax: visible is not a valid member of TextButton “Players.RinkyD1nk.PlayerGui.MasterGui.Menu.GameButton”

Code:

script.Parent.Activated:Connect(function()
	local plr = game.Players.LocalPlayer
	local MGUI = plr.PlayerGui.MasterGui
	local MenuButtons = plr.PlayerGui.MasterGui.Menu:GetChildren()
	for i, v in pairs(MenuButtons) do
		v.visible = false
	end
end)

Hey there, @RinkyD1nk

The problem lies in how you’re attempting to make these elements invisible. You should use the Visible property instead of visible.

Here’s the corrected code:

script.Parent.Activated:Connect(function()
    local plr = game.Players.LocalPlayer
    local MGUI = plr.PlayerGui.MasterGui
    local MenuButtons = plr.PlayerGui.MasterGui.Menu:GetChildren()
    
    for i, v in pairs(MenuButtons) do
        v.Visible = false
    end
end)

In this code, we use v.Visible = false to set the Visible property to false, which will effectively hide the GUI elements.

If you have any more questions or encounter further issues, please don’t hesitate to ask for assistance.

Best regards,
[Zero]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.