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?
--use equal marks not dashes local UIS = game:GetService("UserInputService") --Mouse.KeyDown deprecated local player = game.Players.LocalPlayer local mouse = player:GetMouse() local gui = script.Parent local frame = gui.Frame --gameProcessed event determines whether a core gui, like the chat, is active at the time the key is pressed. therefore, this event will not fire if you are typing in the roblox chat UIS.InputBegan:Connect(function(key,gameProc) if not gameProc and key.KeyCode == Enum.KeyCode.G then frame.Visible = not frame.Visible --sets to opposite value end end)
Accept and upvote if this helped