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

User Input ?

Asked by
Spectrobz 140
8 years ago

So basically I'm willing to make a basic key detection event.

I've been using the InputBegan event fromUserInputService, yet this is the issues :

" This event will always fire regardless of game state "

The scripts detects the keys pressed even when a player is typing, which is an issue. Do you know a way to disable the event while the player is typing?

( I'm not using KeyDown event for reasons )

0
Well, i can suggest that you could make an exception table with the keys that you don't want to be pressed. ( Like, local NotTriggered = {"a","b","c"} ) CrammelApple 50 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

Here is a fix :P

local UIS = game:GetService'UserInputService'

UIS.InputBegan:connect(function(Input,gameProcessedEvent)
    if Input.UserInputType == Enum.UserInputType.Keyboard and not gameProcessedEvent then
        if Input.KeyCode == Enum.KeyCode.W then -- Change W  to the actual key being pressed
            -- Stuff
        end
    end
end

gameProcessedEvent checks if the game processed the event which would mean they chatted.

0
If GPE is true, they are typing. If it's false they are not. Just clarifying :) Perci1 4988 — 8y
Ad

Answer this question