The code is in a LocalScript
Player - game.Players.LocalPlayer
mouse - player:GetMouse()
gui - script.Parent
frame - gui.frame
open - false
function.PressG(key)
if (key == "g") then
if (Open == false) then
frame.Visible = true
open = true
elseif (open == true) then
frame.Visible = false
open = false
end
end
end
Mouse.KeyDown:Connect(PressG)
Have I done something wrong?

3 comments
Please use https://developer.roblox.com/api-reference/class/UserInputService KeyDown should not be used in new code
You're using two different open functions. Lua relies on capitalization so change line 8 to a lowercase "O". Also you must add the key parameter to when you call the function as well else it will be marked as nil. Dashes are not a viable way to set a variable, you must use an equal sign.
Thank you you two for the feedback, it as helped a lot.