Toggle gui not working

Hey gamers, I’m trying to create a simple script that opens and closes a gui. I have no clue why this isn’t working. I’ve tried various different solutions I got from the internet, including the devforum, but nothing works.

Explorer:
image

Script

local click = script.Parent.MouseButton1Click
local menu = game.StarterGui.Menu.Frame

local function toggle()

end

click:Connect(function()
	if menu.Visible == true then
		menu.Visible = false
	else
		menu.Visible = true
	end
end)
1 Like
local click = script.Parent
local client = game:GetService("Players").LocalPlayer
local menu = client.PlayerGUI.Menu.Frame

click.Activated:Connect(function()
	menu.Visible = not menu.Visible
end)

You were changing the frame in StarterGUI and not PlayerGUI.
Also, interact with UI objects on the client (LocalScript).

three things:

I wouldn’t make a Click variable instead I would do script.Parent.MouseButton1Click:Connect(function()

Also Changing the ui needs to be done in a local script not a server script

Also the menu variable should be getting the player’s playergui instead of startergui.