How can I make it that when a text button is visible and you press a certain key on your keyboard the frame becomes not visible

How can I make it that when a text button is visible and you press a certain key on your keyboard the frame becomes not visible

1 Like

I think those resources should help you:

-- LOCAL SCRIPT <---- Could have it inside StarterGui

local UserInputService = game:GetService("UserInputService")
local frame = -- Frame location here

UserInputService.InputBegan:Connect(function(input)
   if input.Keycode == Enum.KeyCode.X then -- Change the key to whatever you need
      frame.Visible = not frame.Visible
   end
end)

I would highly recommend learning it like @HackItsGood said. Also search around and see if you can find it before posting. Thank you and hope this helps.

3 Likes

ok thank you i really appreciate it

in the output it says

Keycode is not a valid member of InputObject "InputObject"

KeyCode my bad it was just a typo. However I would still recommend learning about it so you know how to face these mistakes.

Edit:

if input.KeyCode == Enum.KeyCode.X then -- This is the correct line now

ok thanks :grinning: :smile: :smiley: :grinning_face_with_smiling_eyes: