Problem with UserInputService

So…Whenever I make any keybinds using uis, I always hate the part when you chat it activates the thing, So I really wanna solve this problem, If like there is any solution for it or maybe any other ways besides it, Then I would quite appreciate it!

UserInputService passes in a parameter to events like InputBegan called gameProcessedEvent. If this parameter is true, then you can ignore the input because it was “processed by the game”, e.g. the user is typing in the chat box.

For example:

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
	if gameProcessedEvent then
		-- Ignore input, it was observed by the game already
		return
	end

	print("Unprocessed user input occurred!")
end)
2 Likes

Very beginner scripter Don’t know if this is a worse practice but I mostly use ContextActionService when I want to avoid triggering such things.

1 Like

Definitely a valid suggestion! ContextActionService is usually preferred over UserInputService if it works for your use case, since it’s newer and provides a simpler API. However, some niche cases may not work such as activating UI with a gamepad ButtonA, since Roblox always treats it as “Processed”, even if you want to bind something to it at a higher priority.

By default, ContextActionService automatically ignores any input that’s processed by the game, whereas UserInputService provides it as an argument that you can do with as you need.

3 Likes