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

Im having trouble with a localscript to hide a gui?fffffffffffffffffffffffffffff

Asked by 6 years ago

So i made a gui and want to add a Show/Hide button because its very big and takes up much of the screen. What i tried is making a new textbutton and making a localscript inside of it with following content:

script.Parent.MouseButton1Click:Connect(function()

game.StarterGui.FGHUB.MainFrame.Visible = false
game.StarterGui.FGHUB.UpperLine.Visible = false
game.StarterGui.FGHUB.DownLine.Visible = false
game.StarterGui.FGHUB.LeftLine.Visible = false
game.StarterGui.FGHUB.RightLine.Visible = false
game.StarterGui.FGHUB.Login.Visible = false
game.StarterGui.FGHUB.Password.Visible = false
game.StarterGui.FGHUB.Username.Visible = false
game.StarterGui.FGHUB.FGHub.Visible = false



end)

altough the frames dont turn invisible And i dont know what to do

Help would be appreciated

0
You are editing the startgui which isnt in the player,use playergui which is inside each player instance tobhyyy 26 — 6y
0
I recommend using a remote event AltNature 169 — 6y
0
username and password frames? are you making a scam game? MathijsM2006 12 — 6y

1 answer

Log in to vote
4
Answered by 6 years ago

This wont work because your taking the StarterGui, You need to take the Player's PlayerGui.

READ THIS: If you want it to not only hide and also show, I prefer you use the last script. If you want it to only hide, I prefer you use the 3rd script.

Here is the fixed script:

local Player = game.Players.LocalPlayer -- Gets the player
local PlayerGui = Player:WaitForChild("PlayerGui") -- Gets the player's PlayerGui/Guis
local FGHUB = PlayerGui.FGHUB -- To make it more nicer, Gets the FGHUB Gui

script.Parent.MouseButton1Click:Connect(function()
    FGHUB.MainFrame.Visible = false
    FGHUB.UpperLine.Visible = false
    FGHUB.DownLine.Visible = false
    FGHUB.LeftLine.Visible = false
    FGHUB.RightLine.Visible = false
    FGHUB.Login.Visible = false
    FGHUB.Password.Visible = false
    FGHUB.Username.Visible = false
    FGHUB.FGHub.Visible = false
end)

If you want it to not only hide and also show use this script:

local Player = game.Players.LocalPlayer -- Gets the player
local PlayerGui = Player:WaitForChild("PlayerGui") -- Gets the player's PlayerGui/Guis
local FGHUB = PlayerGui.FGHUB -- To make it more nicer, Gets the FGHUB Gui

script.Parent.MouseButton1Click:Connect(function()
    if FGHUB.MainFrame.Visible == true then -- Checks if it's visible
        FGHUB.MainFrame.Visible = false
        FGHUB.UpperLine.Visible = false
        FGHUB.DownLine.Visible = false
        FGHUB.LeftLine.Visible = false
        FGHUB.RightLine.Visible = false
        FGHUB.Login.Visible = false
        FGHUB.Password.Visible = false
        FGHUB.Username.Visible = false
        FGHUB.FGHub.Visible = false
    else -- Checks if it's not visible/invisible
        FGHUB.MainFrame.Visible = true
        FGHUB.UpperLine.Visible = true
        FGHUB.DownLine.Visible = true
        FGHUB.LeftLine.Visible = true
        FGHUB.RightLine.Visible = true
        FGHUB.Login.Visible = true
        FGHUB.Password.Visible = true
        FGHUB.Username.Visible = true
        FGHUB.FGHub.Visible = true
    end
end)

If you want it more nicer, Organized and shorter use this script:

local Player = game.Players.LocalPlayer -- Gets the player
local PlayerGui = Player:WaitForChild("PlayerGui") -- Gets the player's PlayerGui/Guis
local FGHUB = PlayerGui.FGHUB -- To make it more nicer, Gets the FGHUB Gui

script.Parent.MouseButton1Click:Connect(function()
    FGHUB.Enabled = false
end)

If you want it more nicer, Organized, Shorter and you want it to not only hide it and also show use this script:

local Player = game.Players.LocalPlayer -- Gets the player
local PlayerGui = Player:WaitForChild("PlayerGui") -- Gets the player's PlayerGui/Guis
local FGHUB = PlayerGui.FGHUB -- To make it more nicer, Gets the FGHUB Gui

script.Parent.MouseButton1Click:Connect(function()
    if FGHUB.Enabled == true then -- Checks if it's visible
        FGHUB.Enabled = false
    else -- Checks if it's not visible/invisible
        FGHUB.Enabled = true
    end
end)

If this helped you please accept my answer that would be really appreciated.

-MajinBluee

0
FGHUB.MainFrame.Visible = FGHUB.MainFrame.Visible or even better make a variable of what Visible is User#5423 17 — 6y
0
Nice answer. However if statements are NOT needed. OP can just write FGHUB.Enabled = not FGHUB.Enabled User#19524 175 — 6y
Ad

Answer this question