How to make a GUI disappear when a button is clicked

use visible but u just do if the script is in the button

local frame = script.Parent.Parent:WaitForChild("Frame")
1 Like

Okay. before i edit script again. im gonna get some info so i can make sure if it works. Do you have 1 frames or screen gui being visible and another 1 frames or screengui being not visible?

Also do that what they said. @LifeDigger

image

OMG I am soooo confused lol. :frowning:

Can you show your script again?

What do u want me to show u?? I have changed it soo much from my old script and nothing works. All I have been given is confusion

That’s why i asked. Can you show it so i can see what you’re doing wrong if you’re doing something wrong.

To be honest I have no clue anymore

local frame = script.Parent.Parent:WaitForChild("Frame")

local wow = script.Parent

wow.MouseButton1Click:Connect(function()

frame.Visible = false

end)

I don’t think you need a :WaitForChild() for that. Is it not detecting the click? Try adding prints inside the .MouseButton1Click event to see if it fires. If it still jot detecting the click maybe something covering the button.

Put this in a LocalScript (NOT A Script) inside the button:

local button = script.Parent
local StartUI = button.Parent
local frame = StartUI:WaitForChild("Frame")
button.MouseButton1Click:Connect(function()
     frame.Visible = false
end)
1 Like

This is simple, just create your screen gui. Put a frame inside, name it what you like. Then put your text button in, then add a script the screen gui and it should look something like this.

Local Frame = script.Parent.Frame -- put the name of your frame
Local Button = script.Parent.TextButton -- Put the name of your text button

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

Try this. Not assigning a variable for the button as there is zero point. Follow this word by word.

local player = game:GetService("Players")
local frame = player.LocalPlayer.PlayerGui.["Start UI"].Frame

script.Parent.MouseButton1Click:Connect(function()
frame.Visible = false
end)
11 Likes