Im trying to make a button that hides a whole gui for my clicker game so i can make a sword fighting room.
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | if script.Parent.Text = = "Hide Game" then |
3 | game.StarterGui.Game.Background = false |
4 | script.Parent.Text = "Show Game" |
5 | else |
6 | game.StarterGui.Game.Background = false |
7 | script.Parent.Text = "Hide Game" |
8 | end |
9 | end )` |
I've already tried:
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | if script.Parent.Text = = "Hide Game" then |
3 | game.Players.LocalPlayer.PlayerGui.Game.Background = false |
4 | script.Parent.Text = "Show Game" |
5 | else |
6 | game.Players.LocalPlayer.PlayerGui.Game.Background = false |
7 | script.Parent.Text = "Hide Game" |
8 | end |
9 | 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:
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | if script.Parent.Text = = "Hide Game" then |
3 | game.Players.LocalPlayer.PlayerGui.Game.Background.Visible = false |
4 | script.Parent.Text = "Show Game" |
5 | else |
6 | game.Players.LocalPlayer.PlayerGui.Game.Background.Visible = true |
7 | script.Parent.Text = "Hide Game" |
8 | end |
9 | end ) |
Hope this helped.
But you also have to add the ending right? Like this.
01 | script.Parent.MouseButton 1 Click:connect( function () |
02 | if script.Parent.Text = = "Hide Game" then |
03 | game.Players.LocalPlayer.PlayerGui.Game.Background.Visible = false |
04 | script.Parent.Text = "Show Game" |
05 | else |
06 | game.Players.LocalPlayer.PlayerGui.Game.Background.Visible = true |
07 | script.Parent.Text = "Hide Game" |
08 | end |
09 | end ) |
10 |
11 | script.Parent.MouseButton 1 Click:connect(onClicked) |