function C(actionName, userInputState, inputObject) if userInputState == Enum.UserInputState.Begin then script.Parent.Parent.Classes.Backing.Visible = true print("C") else if script.Parent.Backing.Visible == true then script.Parent.Parent.Classes.Backing.Visible = false end end end game.ContextActionService:BindActionToInputTypes("keyPress", C, false, Enum.KeyCode.C)
When I press the letter C the GUI pops up but then it closes instantly. How would I toggle the GUI so that when I press it the GUI stays up and if I press C when the GUI is up the GUI will Close?
KeyDown alternative;
local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local back = script.Parent.Parent.Classes.:FindFirstChild('Backing') mouse.KeyDown:connect(function(key) if key:lower() == 'c' then back.Visible = not back.Visible end end)