I press G and the GUI opens like it is meant to but when I press G again it doesn't close.
local m = game.Players.LocalPlayer:GetMouse()
isOpen = script.Parent.ScreenGui.Frame.Visible
m.KeyDown:connect(function(k)
k = k:lower()
if k == "g" then
if isOpen == false then
script.Parent.ScreenGui.Frame.Visible = true
elseif isOpen == true then
script.Parent.ScreenGui.Frame.Visible = false
end
end
end)

3 comments
KeyDown is deprecated, use UserInputService.
ya know you could just use - script.Parent.ScreenGui.Frame.Visible = not script.Parent.ScreenGui.Frame.Visible
so you wont need to use if statements nor booleans