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

UserInputService Keycode fires when typing. How to fix?

Asked by 4 years ago

When I press E on my keyboard it fires the function, but when I am typing aswell it also fires it, how do I make it so when I am typing, it wont fire.

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E then
        print("E")
    end
end)

2 answers

Log in to vote
0
Answered by 4 years ago

There are two parameters to InputBegan. The first one is the input, and the second one is if the player is doing something else with that key so do:

UIS.InputBegan:Connect(function(input, gp)
    if input.KeyCode == Enum.KeyCode.E and not gp then
        print("E")
    end
end)

-Ducky

Developer

Youtuber

Ad
Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

Use IsTyping. It will check if they are interacting with UI or not. On your second line put:

if input.KeyCode == Enum.KeyCode.E and not IsTyping then

That should work! Mark as the answer if it did.

Answer this question