It is for just the player. It is inside Starter GUI.
Players have their own GUI, which is located in the Players Service
However you can locate their gui like this.
game.Players.LocalPlayer:FindFirstChild("PlayerGui") -- direct its path to the gui.
That worsened the problem. The current problem is that the GUI isn’t becoming visible when I click the button. Here is the script:
local menuButton = script.Parent
local menu = game.StarterGui.MenuGUI.Menu
local menuOpen = false
local function openOrCloseMenu ()
if not menuOpen then
menuOpen = true
menu.Visible = true
print("Image Shown")
else
menuOpen = false
menu.Visible = false
print("Image Closed")
end
end
menuButton.Activated:Connect(openOrCloseMenu)
Oh, if ur doing that to a gui do menu.Enabled = (false or true).
If its a frame or etc they use Visible
Ok, i see the problem here, just change game.StarterGui.MenuGUI.Menu
, this line is looking what its in the starter gui, but when you start the game, everything on the starter gui moves to the player gui, so its basically looking in a empty folder, in order to work it should be something like
local menu = menuButton.Parent.Menu
(I tried this change with your script and it worked perfectly)
robloxapp-20220221-1601114.wmv (177.3 KB)
because since the button is inside the starter gui it will be moved to the starter gui with everything that was in there, in order to change gui is always better to use parents and childs
You shouldnt be calling the StarterGui.
Get the PlayerGui as the GUI in StarterGui Clones and Parents to PlayerGui when youre loaded in.
Need more info on what PlayerGui is? Click Here to view DevHub Article
Here’s a screenshot of my situation:
What should I do in this case? I tried this:
local gameMenu = menuButton.Parent
local gameMenuGui = gameMenu.Parent
local StarterGUI = gameMenuGui.Parent
local menuGui = StarterGUI.MenuGUI
local menu = menuGui.Menu
It still didn’t work, so what should I do in this case?
then you could try to use the player gui, but instead of locating them like you normally will do with any other folder you must do local menuGui = PlayerGui:WaitForChild("MenuGUI")
, cause the script runs even before things in the starterGui are send to the playerGui, so if you do local menuGui = PlayerGui.MenuGui
it will print an error, WaitForChild waits until MenuGui appears where you are looking (You can also do local example = workspace:WaitForChild("Example", 3)
if you want to put how much time it is waiting for the part to appear, in this case if it can’t locate “Example” after 3 seconds, it will continue to run and left the var = nil)
Remember that to access correctly to the playerGui folder you need to do
local PlayerGui = Players.LocalPlayer:WaitForChild('PlayerGui')
or
local PlayerGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
--If you dont have "Players" set as a var before (local Players = game:GetService("Players"))
Thank you so much! It worked! I’m just marking this message as the solution because this was the last step in fixing it.
Im really glad i could help you!