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

How Does A Text Button in Gui Is clicked And Another Gui Pops Up?

Asked by 11 years ago

Ive Been trying to figure this out for days Please Help!

1 answer

Log in to vote
3
Answered by
drahsid5 250 Moderation Voter
11 years ago

Your title's grammar, amazing. I'm assuming you'd like to know how to make a GUI pop up when you click a text/image button. So, That's what I'll tell you. Sense we'll need the local player's mosue, we'll start off with this:

1repeat wait() until game.Players.LocalPlayer

Why that? So the local player is there before anything else can happen. (Preventing errors) Next we get the mouse;

1local mouse = game.Players.LocalPlayer:GetMouse()

Now, lets be neat, and tell it the directory of our frames and buttons.

1local FirstFrame = script.Parent.Parent --Or wherever your first frame is, the text button is likely inside of it, so this is what you'd usally put
2local PopUpFrame = script.Parent.Parent.Parent.PopUp --Once again, change this to wherever your frame is located.
3local Button = script.Parent --The script will most likely be in the button

Next we add the OnClick function, and the popup.

01function onClick()
02if PopUpFrame.Visible == true then
03    PopUpFrame.Visible = false
04 
05elseif PopUpFrame.Visible == false then
06PopUpFrame.Visible = true
07end
08end
09 
10Button.MouseButton1Click:connect(onClick)

and then your done. The full script would look something like this:

01repeat wait() until game.Players.LocalPlayer
02local mouse = game.Players.LocalPlayer:GetMouse()
03 
04local FirstFrame = script.Parent.Parent --Or wherever your first frame is, the text button is likely inside of it, so this is what you'd usally put
05local PopUpFrame = script.Parent.Parent.Parent.PopUp --Once again, change this to wherever your frame is located.
06local Button = script.Parent --The script will most likely be in the button
07 
08function onClick()
09if PopUpFrame.Visible == true then
10    PopUpFrame.Visible = false
11 
12elseif PopUpFrame.Visible == false then
13PopUpFrame.Visible = true
14end
15end
16 
17Button.MouseButton1Click:connect(onClick)
0
it doesnt work FPSStudioDidi 1 — 11y
0
That's because you didn't change the locations of the frames and text button. drahsid5 250 — 11y
0
oh o thanks FPSStudioDidi 1 — 11y
0
If it worked then hit the button that says that I'd answered your question. drahsid5 250 — 11y
Ad

Answer this question