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

Why wont this show a Gui? (closed)

Asked by 10 years ago

Ive tried lots of things but it wont show a gui. theres nothing in the output so why wont it show?

1local button = game.StarterGui.ScreenGui.Help
2 
3button.MouseButton1Click:connect(function()
4 
5game.StarterGui.Info.Information.Active= true
6 
7end)
1local function clicked()
2 
3game.StarterGui.Info.TextBox.Visible=true
4wait(10)
5    game.StarterGui.Info.TextBox.Visible=false
6 
7    game.StarterGui.ScreenGui.TextButton.MouseButton1Click:connect(clicked)
8end

3 answers

Log in to vote
1
Answered by
Redbullusa 1580 Moderation Voter
10 years ago

First of all, you really don't want to adjust the GUIs in the StarterGui, because that is a service that gives a copy of the GUI to the players' PlayerGui, therefore the change won't be visible right away.

What the code should be accessing is the players' PlayerGui, because that's where the players' real-time displayed GUIs are stored.

1-- Since I'm using LocalPlayer, this MUST be in a LocalScript.
2-- Since this is supposed to be in a LocalScript, a :WaitForChild() method is recommended to utilize.
3 
4local GUI = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
5local button = GUI:WaitForChild("Help")
6button.MouseButton1Click:connect(function()
7    game.Players.LocalPlayer.PlayerGui.Info.Information.Active= true
8end)
1-- For this function, put your connection line OUTSIDE; otherwise the function won't fire if the connection line is within an 'unfired' function.
2 
3local function clicked()
4    game.Players.LocalPlayer.PlayerGui.Info.TextBox.Visible=true
5    wait(10)
6    game.Players.LocalPlayer.PlayerGui.Info.TextBox.Visible=false
7end
8game.Players.LocalPlayer.PlayerGui.ScreenGui.TextButton.MouseButton1Click:connect(clicked)

If your script is within one of the GUIs, then I recommend referring your GUI objects starting from the script (such as script.Parent).


EXAMPLE

Let's assume your script is within ScreenGui. You don't necessarily have to have a LocalScript this way. You could use script.Parent.Parent.Info to access the Info GUI.

1local GUI = script.Parent
2local button = GUI:WaitForChild("Help")
3local InfoGui = GUI.Parent:WaitForChild("Info")
4button.MouseButton1Click:connect(function()
5    InfoGui.Information.Active= true
6end)
01local GUI = script.Parent
02local TB = GUI:WaitForChild("TextButton")
03local InfoGui = GUI.Parent:WaitForChild("Info")
04 
05local function clicked()
06    InfoGui.TextBox.Visible=true
07    wait(10)
08    InfoGui.TextBox.Visible=false
09end
10 
11TB.MouseButton1Click:connect(clicked)
12-- NOTE: You don't have to have a plethora of variables with a :WaitForChild() method, especially if the script is server-sided.
13--But it's a habit for me because I'm quite meticulous when it comes to scripting, as I want to avoid as much errors as possible.
Ad
Log in to vote
1
Answered by
Irvene 5
10 years ago
1script.Parent.MouseButton1Click:connect(function()
2 
3game.StarterGui.TextButton.Visible = true
4 
5end)
0
If it's not a TextButton change it to what it is. Irvene 5 — 10y
Log in to vote
0
Answered by 10 years ago
1script.Parent.MouseButton1Click:connect(function()
2 
3script.Parent.Parent.VISIBLEME.Visible= true
4 
5end)

You need to tell it where you want it to click

Put the script inside the button you want to become visible

EDIT: Make a button and make the button name that you want to be visible be called VISIBLEME

If it does then go to the wiki and learn more basics.

0
didnt help bubbaman73 143 — 10y
0
Forgot something. Sorry. And also changing what is in StarterGui does not change in the Player's Guipack, it changes after you reset. lightpower26 399 — 10y
0
so what do i put it in? bubbaman73 143 — 10y

Answer this question