Hello, I have made a script that deploys the player using user input service. Everything works perfectly, however when a player is typing, and accidentally press the space bar (Which is the button I chose to deploy), it deploys the player still even when they are typing. I know this is a general problem, but is there a way to not fire a UIS Keycode function when a player is using chat or for some other reason? It can be annoying because you are typing and then it suddenly deploys you in the game, despite not being ready yet. Please help.
In addition to passing the InputObject
of the input as an argument, InputBegan
/ InputEnded
/ InputChanged
all also pass another which roblox refers to as gameProcessedEvent
. Basically, this value determines whether or not the game engine has observed the input and processed it internally. For most cases, this is when the player is typing in a text box (and to be more specific, the chat box in the chat ui). If they are typing in a chat box when the input event fired, gameProcessedEvent
will be true, otherwise it will be false.
UserInputService.InputBegan:Connect(function(input, gpe) if gpe then return end -- if the player is typing in a textbox, cease further execution -- blah blah blaah end)