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?

local button = game.StarterGui.ScreenGui.Help

button.MouseButton1Click:connect(function()

game.StarterGui.Info.Information.Active= true

end)


local function clicked()

game.StarterGui.Info.TextBox.Visible=true
wait(10)
    game.StarterGui.Info.TextBox.Visible=false

    game.StarterGui.ScreenGui.TextButton.MouseButton1Click:connect(clicked)
end

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.

-- Since I'm using LocalPlayer, this MUST be in a LocalScript.
-- Since this is supposed to be in a LocalScript, a :WaitForChild() method is recommended to utilize.

local GUI = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
local button = GUI:WaitForChild("Help")
button.MouseButton1Click:connect(function()
    game.Players.LocalPlayer.PlayerGui.Info.Information.Active= true
end)
-- For this function, put your connection line OUTSIDE; otherwise the function won't fire if the connection line is within an 'unfired' function.

local function clicked()
    game.Players.LocalPlayer.PlayerGui.Info.TextBox.Visible=true
    wait(10)
    game.Players.LocalPlayer.PlayerGui.Info.TextBox.Visible=false
end
game.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.

local GUI = script.Parent
local button = GUI:WaitForChild("Help")
local InfoGui = GUI.Parent:WaitForChild("Info")
button.MouseButton1Click:connect(function()
    InfoGui.Information.Active= true
end)
local GUI = script.Parent
local TB = GUI:WaitForChild("TextButton")
local InfoGui = GUI.Parent:WaitForChild("Info")

local function clicked()
    InfoGui.TextBox.Visible=true
    wait(10)
    InfoGui.TextBox.Visible=false
end

TB.MouseButton1Click:connect(clicked)
-- NOTE: You don't have to have a plethora of variables with a :WaitForChild() method, especially if the script is server-sided.
--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
script.Parent.MouseButton1Click:connect(function()

game.StarterGui.TextButton.Visible = true

end)

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
script.Parent.MouseButton1Click:connect(function()

script.Parent.Parent.VISIBLEME.Visible= true

end)

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