Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] How can I make a UIS Keycode function not interfere with typing?

Asked by 3 years ago
Edited 3 years ago

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.

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
3 years ago

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)
0
THANK YOU SOOO MUCH! ScentedTrashCan 16 — 3y
Ad

Answer this question