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
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