Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you remove and add a GUI with the use of a Button?

So, I made a button, and what i want it to do is there is a GUI on screen, and i want it that if you press the button, it hides the GUI on screen, and replaces it with another one. Like you start off with a GUI on screen that says something like 'Hello', and then when you press the button, the GUI changes and then the GUI says 'How are you?' (As an example)

Edit: I dont want to make a new GUI, like i made the two GUI's, i just need them to like switch places when you press a button. Like you start off with one, which has already some buttons and stuff in, but when you press a button, the first GUI disappears, and the second one appears. Then you press the button again, and you get the first GUI again.

Please help me out! I've tried everything I could think of!

5 comments

0

I think the Problem should be solved if u change the Visibility Property of the GUIs and make them invisible/visible!

0

Did it help u?

0

1DoctorProctor can you write me a script so that i can just copy it? Cuz i dont know what the script is

0

Uhmm...

0

This isn't a place to request for scripts.

3 answers

You don't have to change whole gui you can just change the text of TextLabel inside of it

local Player = game.Players.LocalPlayer
local Label = Player.PlayerGui:WaitForChild("ScreenGui").TextLabel
ExampleButton.MouseButton1Click:Connect(function()
       Label.Text = "How are you?"
end)

Note: This will not be formated very well because I am ob phone

4 comments

0

But the problem is i have multiple buttons for the first and second GUI, (Cuz i made them), and i want them to like switch places in the click of a button. Also, The buttons does do something to the cac. So yeh. I just need the gui's to switch.

0

Then you can destroy that Gui and make new one by local gui = Instance.new("ScreenGui") gui.Parent = game.Playere.LocalPlayer.PlayerGui

0

karlo_tr10 doesnt work

0

game.Players*

I'm thinking your wanting to make a dialog type thingy.

You may want to look into using tables to accomplish this...maybe something like this(did not test)

local textTable = {'Hi, John';'How are you today?';'Lolz don't care'}

local key = 1

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.TextLabel.Text = textTable[key]
	key = key + 1
end)

Something along those lines :)

if your wanting the textbox to disapear then use transparency or look into TweenPosition and such.

button1.MouseButton1Click:connect(function()
	GUI1.transparency = 1
	GUI2.transparency = 0
end)
button2.MouseButton1Click:connect(function()
	GUI1.transparency = 0
	GUI2.transparency = 1
end)

It should work like this!

2 comments

0

Which type of script is it? A normal script? Or a local script?

0

Also, I have one script in that button already, so i tried it with one normal script and a local script, and it didnt work. I copied out your command, (Also changed the button1, GUI1 and GUI2 to locate it) and nothing.

This discussion is preserved as it was. New answers, comments, and votes are closed.