I created a script that would open/close an Options menu when pressing the "O" key on your keyboard. However, when I tried typing inside a TextBox that the frame "menu" had inside it, it would cut off the menu when I pressed "O". Here's the script:
local uis = game:GetService("UserInputService") uis.InputBegan:connect(function(input) if input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == Enum.KeyCode.O then print("Success!") local menu = script.Parent.options.menu local open = menu.isOpen if open.Value == true then -- Menu is open menu.Visible = false open.Value = false else -- Menu is not open menu.Visible = true open.Value = true end end end end)
The problem is that this script is triggered when "O" is pressed, even when a player is typing in the radio. How do I make this script connect the function when the player is not typing?
You need to pass a second argument through the () which is called processed now this detects if the player is chatting etc which is why your having this issue because you are only detecting keyboard input.
local Player = game.Players.LocalPlayer local UIS = game:GetService("UserInputService") UIS.InputBegan:connect(function(InputObject,Processed) if not Processed then if InputObject.KeyCode == Enum.KeyCode.O then print("Success! ") local menu = script.Parent.options.menu local open = menu.isOpen if open.Value == true then -- Menu is open menu.Visible = false open.Value = false else -- Menu is not open menu.Visible = true open.Value = true end end end end)
local uis = game:GetService("UserInputService") uis.InputBegan:connect(function(input,gameprocessed) if gameprocessed == false then if input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == Enum.KeyCode.O then print("Success!") local menu = script.Parent.options.menu local open = menu.isOpen if open.Value == true then -- Menu is open menu.Visible = false open.Value = false else -- Menu is not open menu.Visible = true open.Value = true end end end end end)
When the focus is on a gui then gameprocessed will be true. The function will be fired when the focus is not on a gui, so when gameprocessed is false.