So I have 2 scripts to press a keybind and if you press that keybind it opens/closes a GUI. The problem is, if I have 2 of them, on 2 different buttons/frames/screenguis, only one of them works. I have a game that I want to make where a player can build (that's only what I am thinking of making right now) and I have a Frame for the buildings (by pressing N) and I also have a ScrollingFrame for help (by pressing H) But only the ScrollingFrame works. Here are both of the codes:
(ScreenGUI) Buildings (Frame) BFrame (LocalScript) OpenN:
local toggle = false -- false is Off; true is On
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
print("N was pressed")
if toggle == false then
toggle = true
script.Parent.Visible = true
else
toggle = false
script.Parent.Visible = false
end
end
end
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.N)
(ScreenGUI) HelpUI (ScrollingFrame) HelpUI (LocalScript) OpenH:
local toggleH = false -- false is Off; true is On
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
print("H was pressed")
if toggleH == false then
toggleH = true
script.Parent.Visible = true
else
toggleH = false
script.Parent.Visible = false
end
end
end
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.H)

1 comment
What is wrong here? And why can't I open up the Buildings GUI?