Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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!

0
I think the Problem should be solved if u change the Visibility Property of the GUIs and make them invisible/visible! 1DoctorProctor1 0 — 5y
0
Did it help u? 1DoctorProctor1 0 — 5y
0
1DoctorProctor can you write me a script so that i can just copy it? Cuz i dont know what the script is phantommarionnete 0 — 5y
0
Uhmm... 1DoctorProctor1 0 — 5y
0
This isn't a place to request for scripts. RyanTheLion911 195 — 5y

3 answers

Log in to vote
0
Answered by
karlo_tr10 1233 Moderation Voter
5 years ago

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

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. phantommarionnete 0 — 5y
0
Then you can destroy that Gui and make new one by local gui = Instance.new("ScreenGui") gui.Parent = game.Playere.LocalPlayer.PlayerGui karlo_tr10 1233 — 5y
0
karlo_tr10 doesnt work phantommarionnete 0 — 5y
0
game.Players* karlo_tr10 1233 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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.

Log in to vote
0
Answered by 5 years ago
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!

0
Which type of script is it? A normal script? Or a local script? phantommarionnete 0 — 5y
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. phantommarionnete 0 — 5y

Answer this question