So I made some UI and I remembered I suck at scripting. What I want to do is open the UI when a button on the keyboard is pressed.
I know how to open the UI on a timer with a script but idk how to open it when a button is pressed.
What api[ or whatever it’s called ] could I use to achieve this?
Wouldn’t that only work if you clicked it with your mouse? Or clicked it on mobile?
What I’m trying to do is open the ui when a button on the keyboard is pressed, like f or something.
Sorry if I sound dumb…
Oh my bad, but lets say you want to use E

1 Like
local UIS = game:GetService("UserInputService")
local toggle = false
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if toggle then
script.Parent.Visible = false
toggle = false
elseif not toggle then
script.Parent.Visible = true
toggle = true
end
end
end)
Local script place it inside whatever UI you want to “open”. This script will toggle the visibility of the particular UI element whenever the “E” key is pressed.
1 Like