local player = game.Players.LocalPlayer
local inventoryVis = player.PlayerGui.Inventory.Visible
UIS = game:GetService("UserInputService")
UIS.InputBegan(function(input, process)
if not process then
if input.KeyCode == Enum.KeyCode.G and inventoryVis == false then
--fetch inventory
inventoryVis = true
elseif input.KeyCode == Enum.KeyCode.G and inventoryVis == true then
--close inventory
inventoryVis = false
end
end
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.

3 comments
Thanks!!
@KiHeros 1) You shouldn't use variables to get properties, like you did with 'inventoryVis'. You will store the value and not the key (property) to it. So, if 'Inventory'-s Visible property does change, the variable will not. You should just store the 'Inventory' object itself. 2) At line 11, you wrote 'else then' which will error.
PS. I know you have helped @konichiwah1337 further, but you should've updated the code, so other people can get help if they stumble upon similar problem.