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