My Menu GUI is not working

Why is my Menu GUI not working? I am making a basic menu and just started on it. When I test it the buttons that I am using to make fames visible and close the menu are not working at all.
This is what I have atm.

local Frame = game.StarterGui.ScreenGui.Frame
local Frame2 = game.StarterGui.ScreenGui.Frame2
local Play = game.StarterGui.ScreenGui.Frame.Play
local Teams = game.StarterGui.ScreenGui.Frame.Teams
local Close = game.StarterGui.ScreenGui.Frame2.close
local Jedi = game.StarterGui.ScreenGui.Frame2.jedi
local Sith = game.StarterGui.ScreenGui.Frame2.sith

Frame.Visible = true
Frame2.Visible = true

Play.MouseButton1Click:Connect(function()
	Frame.Visible = false
	Frame2.Visible = false
end)

Teams.MouseButton1Click:Connect(function()
	Frame2.Visible = true
end)

Close.MouseButton1Click:Connect(function()
	Frame2.Visible = false
end)

I have never made a menu before so please forgive me if I made some obvious mistake.

The problem is that you’re hooking events to the StarterGui version of your menu. StarterGui elements are not rendered to the visitor but rather serve as a container for which Guis are copied from to the player. You’ll need to access the LocalPlayer’s PlayerGui to make changes to the Gui that visitor actually see.

2 Likes

Oh. Thank you. Does this mean I need to move the location of my GUI parts?

No, you don’t. All Gui elements inside of StarterGui gets copied over to a Folder under the Player called PlayerGui. All you need to do to fix your script is change the StarterGui to PlayerGui.

local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui

local ScreenGui = PlayerGui.ScreenGui
local Frame = ScreenGui.Frame

...etc..
1 Like
local Gui = game.Players.LocalPlayer.PlayerGui.ScreenGui
local Frame = Gui.Frame
local Frame2 = Gui.Frame2
local Play = Frame.Play
local Teams = Frame.Teams
local Close = Frame2.close
local Jedi = Frame2.jedi
local Sith = Frame2.sith

Frame.Visible = true
Frame2.Visible = false

Play.MouseButton1Click:Connect(function()
	Frame.Visible = false
	Frame2.Visible = false
end)

Teams.MouseButton1Click:Connect(function()
	Frame2.Visible = true
end)

Close.MouseButton1Click:Connect(function()
	Frame2.Visible = false
end)

Did I do it right?
It does not seem to be working.

Yep, looks good to me! Have you tested it yet?

I did. It doesn’t seem to be working. I don’t know what is wrong.

Are there any errors? What part doesn’t work?

To answer your question. None of the buttons do anything when I click on them and I do not see any error notifications.

Where is the script located? And is it a localscript? The script should be located inside either the ScreenGui or the PlayerScripts

Oh thanks. It was not a localscript. That was a stupid mistake, everything works now. Thank you soooo much!

Ah yes. Remember you can only get the LocalPlayer inside a LocalScript

1 Like