01 | local player = game.Players.LocalPlayer |
02 | local inventoryVis = player.PlayerGui.Inventory.Visible |
03 |
04 | UIS = game:GetService( "UserInputService" ) |
05 |
06 | UIS.InputBegan( function (input, process) |
07 | if not process then |
08 | if input.KeyCode = = Enum.KeyCode.G and inventoryVis = = false then |
09 | --fetch inventory |
10 | inventoryVis = true |
11 | elseif input.KeyCode = = Enum.KeyCode.G and inventoryVis = = true then |
12 | --close inventory |
13 | inventoryVis = false |
14 | end |
15 | end |
16 | end ) |
Trying to get it so that whenever the player presses G, an inventory GUI becomes visible, and turns it off if its already visible.
01 | local player = game.Players.LocalPlayer |
02 | local inventoryVis = player.PlayerGui.Inventory.Visible |
03 |
04 | UIS = game:GetService( "UserInputService" ) |
05 |
06 | UIS.InputBegan:connect( function (input, process) |
07 | if not process then |
08 | if input.KeyCode = = Enum.KeyCode.G and inventoryVis = = false then |
09 | --fetch inventory |
10 | inventoryVis = true |
11 | else then |
12 | --close inventory |
13 | inventoryVis = false |
14 | end |
15 | end |
16 | end ) |
this should fix it all I did was remove the input.KeyCode == Enum.KeyCode.G and inventoryVis == true also you where missing "connect"
hope this helped. ~KIHeros