Im trying to make a button that hides a whole gui for my clicker game so i can make a sword fighting room.
script.Parent.MouseButton1Click:connect(function () if script.Parent.Text == "Hide Game" then game.StarterGui.Game.Background = false script.Parent.Text = "Show Game" else game.StarterGui.Game.Background = false script.Parent.Text = "Hide Game" end end)`
I've already tried:
script.Parent.MouseButton1Click:connect(function () if script.Parent.Text == "Hide Game" then game.Players.LocalPlayer.PlayerGui.Game.Background = false script.Parent.Text = "Show Game" else game.Players.LocalPlayer.PlayerGui.Game.Background = false script.Parent.Text = "Hide Game" end end)`
I don't know what you are trying to do with game.Players.LocalPlayer.PlayerGui.Game.Background = false
.
If Background
is a part of the gui, you probably want to make it's property Visible
to false when you want to hide it and to true when you want to show it, like this:
script.Parent.MouseButton1Click:connect(function () if script.Parent.Text == "Hide Game" then game.Players.LocalPlayer.PlayerGui.Game.Background.Visible = false script.Parent.Text = "Show Game" else game.Players.LocalPlayer.PlayerGui.Game.Background.Visible = true script.Parent.Text = "Hide Game" end end)
Hope this helped.
But you also have to add the ending right? Like this.
script.Parent.MouseButton1Click:connect(function () if script.Parent.Text == "Hide Game" then game.Players.LocalPlayer.PlayerGui.Game.Background.Visible = false script.Parent.Text = "Show Game" else game.Players.LocalPlayer.PlayerGui.Game.Background.Visible = true script.Parent.Text = "Hide Game" end end) script.Parent.MouseButton1Click:connect(onClicked)