THE OPENING PART IS WORKING Here is the script
--Ignore lines 1 to 9 thats the working part --Opening part local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() mouse.KeyDown:connect(function(key) if key:lower() == "e" then plr.PlayerGui.Inventory.Main.Visible = true end end) --Closing part mouse.KeyDown:connect(function(key) if plr.PlayerGui.Inventory.Main.Visible == true then if key:lower() == "e" then plr.PlayerGui.Inventory.Main.Visible = false end end end)
No output appears
mouse.KeyDown:connect(function(key) if key:lower() == "e" then plr.PlayerGui.Inventory.Main.Visible = true else plr.PlayerGui.Inventory.Main.Visible = false end end)
You can also simplify your script by using the "not" keyword.
local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() mouse.KeyDown:connect(function(key) if key:lower() == "e" then plr:WaitForChild("PlayerGui").Inventory.Main.Visible = not plr:WaitForChild("PlayerGui").Inventory.Main.Visible --Sets the visibility of the GUI object to the opposite of what it is already, so false is true and true is false. end end)
Gives you less lines in the script, and saves repeating the KeyDown event twice.