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

How can I disable UserInputSerivce when player is not chatting?

Asked by 5 years ago

My code is

local toggle = script.Parent.Frame.Toogle
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)

    if inputObject.KeyCode == Enum.KeyCode.E then --So on

How can I disable it when the player is chatting, it messes up the game if it activates.

Any thoughts?

1 answer

Log in to vote
0
Answered by
BenSBk 781 Moderation Voter
5 years ago

The second argument of UserInputService.InputBegan, is_game_processed, is true if the input has been processed/handled by the game (GUI, etc.) prior to making the event fire:

game:GetService("UserInputService").InputBegan:Connect(function(input, is_game_processed)
    -- If the input has already been processed by the game, return from the function.
    if is_game_processed then
        return
    end
    -- ...
end)
0
It works, thanks! Trooper_Toaster 0 — 5y
Ad

Answer this question