How to make one GUI dissapear and another open when you click a button?

Hey, everyone!

So basicaly, what I’m trying to do at the moment is make a main menu for my game. (sorry if my explanation is bad)

I want to be able to press play on the main menu, which will make the main menu disapear and open a content warning gui.

Problem is - I’m not sure how to make the content warning apear. I already have the main menu gui, the content warning gui., and I made it so when I press the play button, the main menu closes, but other than that I’m not sure what to do, and I can’t find any tutorials on this.

If anyone knows what to do, please let me know!

3 Likes
-- local script under button
local button = script.Parent -- (location of your button)

local frame1 = --(location of frame)
local frame2 = --(location of second frame)

-- .visible is the property that you want to change to make a gui (graphics user interface) appear or disappear

button.MouseButton1Click:Connect(function())
    frame1.Visible = true -- makes the visibility of the first frame visible
    frame2.Visible = false -- makes the visibility of the second frame invisible

end)

here are the basics for you to get started if you have any further questions please ask

3 Likes

Thank you! I’ll test this later.

Have a good day/night! =]

1 Like

Okay, so I forgot to mention that the first gui is buttons and a camera. So basically it’s a main menu, where there’s a camera pointing at parts in the game and two gui text buttons (the play button and the credits button). Once you click on the play buttons the camera gui turns off and you can see the game right away. What I want to do, is that when you click the play button, the main menu disappears and the content warning shows up. (I’m pretty sure this is a little better of an explanation than my original post), so would this make a difference in the script and how?

I see what do you ready so far? If you dont have anything ready I will help you step by step, its taboo here to provide everything without explaining anything, so I will try my best to teach you but worry not its not super complex its one of the first things I made when I first started.

1 Like

to set up the camera if you havent already,

  1. make a folder in workspace called “camera” the folder just makes things more organized you dont want to clutter you workspace in the explorer tab.

2… Place a part, name it something like “camera” this part will be the camera. you can resize it but don rotate it yet because we cant tell where it would make the camera orientate.

  1. add a local script in startplayerscript if you are curious the difference between this and the one above called “startercharacterscript” , its that local scripts in startercharacterscript run whenever the character respawns and local scripts in starterplayerscript run when the player joins. If you want your menu to appear everytime the player respawns place it in startercharacter script

  2. Now add this inside the script

local player = game:GetService("Players").LocalPlayer 
-- every player in a server has their own local script, that local script is unique to them
-- thats how local scripts knows who the player is  (you cannot get the player using game:GetService("Players").LocalPlayer on a server script)
--// Variables
local cam = workspace.[--name of your camera folder]CurrentCamera 
local camPart = cam:WaitForChild("MainCam") -- MainCam is the name of the part of my camera you can change this to yours

player.CharacterAdded:Connect(function(char) -- this waits for when the character is added then connects it to a function
-- this is what the function will do when the character is added
	local plrCam = workspace.CurrentCamera -- gets players camera
	plrCam.CameraType = Enum.CameraType.Scriptable -- resets the camera's settings
	plrCam.CFrame = workspace.cam.Part.CFrame -- sets the CFrame (Coordinate Frame, which is contains the 3d location and orientation of a 3d object) of the camera to the part's CFrame.  So you can just image the player's camera teleporting inside of the part.
end)
  1. Now for making the menu buttons
    add a screen gui in startergui if you havent already, then add a frame inside of that screengui finally add your buttons. Design your buttons and frame however you want.

  2. Then just use this local script for your play button put it under the button

1 Like

Sorry for responding late, I’ve been a little busy with school. I actually managed to do it by editing the camera script I had:

local CurrentCamera = workspace.CurrentCamera
local Part = workspace:WaitForChild("MenuCamera")
local PlayBTN = script.Parent.BG.Play_btn
local WarningFrame = script.Parent:WaitForChild("ContentWarningGUI") 

CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = Part.CFrame

function Play()
	CurrentCamera.CameraType = Enum.CameraType.Custom
	WarningFrame.Visible = true
	script.Parent.BG.Visible = false 
end

PlayBTN.MouseButton1Click:Connect(Play)

Thank you so much for helping and putting up with me though, and sorry for wasting your time!

Have a great day/night! =]

1 Like