Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I disable UserInputSerivce when player is not chatting?

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

✓ Accepted answer

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)

1 comment

0

It works, thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.