How to make a GUI disappear when a button is clicked

Hello,

So I am trying to create a quiz thing were if they get a certain amount of points correct they get promoted. I have a idea of how I am going to do this but I want it so that when they click the start button it then will remove the UI’s at the start then go onto the next ones. I thought it would be to do with something with the enabled thing but I don’t understand it. I am quite new to scripting and don’t use UI’s often so if someone could help me that would be great.

3 Likes

You could change the UI’s visible property with the scripts or just :Destroy().
Using the visible property can be used for making the UI’s show up and disappear.

3 Likes

Not sure on what I am doing really lol. I thought this was correct.

1 Like

This should work, are there any errors?

Nope there is none. I put the print there just to make sure it is runing when I click the UI

I just realized the script is a serverside script, try making it a local script. Also deleting stuff from StarterGui won’t affect the player, try doing:

local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local UI = PlayerGui["Start UI"]
--Continue on

Create a local script inside the button.

local player = game.Players.LocalPlayer
local button = script.Parent

button.MouseButton1Clicked:Connect(function()
-- turn the visible off of all the guis u want or get the GUI and disable it 
end)
2 Likes

If you intend on toggling a frame, you can use the Visible property. This can be done by doing;

Frame.Visible = false
Frame.Visible = true

If you intend on toggling a ScreenGui, you can use the Enabled property. This can be done by doing;

ScreenGui.Enabled = false
ScreenGui.Enabled = true
1 Like

to make it more useful. there you go:

local player = game.Players.LocalPlayer
local button = script.Parent    

button.MouseButton1Clicked:Connect(function()
EnterFrameNameHereWhenuclickbuttonsoitdisappear.Visible = false
EnterAnotherFrameNameuwantittobeshownupafterclickingthebutton.Visible = true
end)

@LifeDigger

It’s still not working.
image

Also anyone know who it is putting the Start UI in [""]?

image

@yLocaI @rottendogDkR @BawTheSeal

it is because you didnt put frame.visible = true. also i recommend renaming these frame name to different so it works. just not same frame name. how is it supposed to close it and open another when frame names are same when you put in?

What do you mean by frame???

You were supposed to use enabled and not visible since it is a gui and not a frame.

Do you just need the GUI transparent or destroyed/deleted?

image

HWYYYY NOOWW!!!

thats default name that they make it to when you make a frame and it says that “frames” so i recommended to name these frame name to different and put the frames name to the frame name that you name it to. so it works. just like.

Frame.Visible = false

Wrong. :x: Now onto another script:

Frame.Visible = false
Frame.Visible = true

Wrong again. :x: Onto another script.

YourFrameName(notsupposedtobesame).Visible = false
YourFrameName(notsupposedtobesame).Visible = true

Correct. right. :white_check_mark:

But why u talking about frames? My script is disable the screen UI?

1 Like

to disable your Gui screen right.

this is what you mean?

You should get PlayerGui instead of StarterGui. Everything inside StarterGui clones into player’s PlayerGui when player joins to the game and player is seeing PlayerGui, not StarterGui.

Yes that is what I was thinking