How to make a GUI with a Keybind not open if they're talking in chat?

Hello! I have this keybind to open a GUI, which is X, but whenever someone puts X in chat, the GUI Opens. How can I fix this?

Thanks! Any help will be appreciated.

The second argument in InputBegan is gameProcessedEvent which is what you want to use in this case.
So:

UserInputService.InputBegan:Connect(function(input, gameProcess)
    if gameProcess then return end    -- If gameProcess returns true, it means the player is in chat or doing something similar, so stop the code here
    -- Otherwise, the player is not using chat
end)

You can read more on it here, the post explains it far better than I could.

3 Likes

I believe they have a thing called GameProcessed as the second parameter for UserInputService. Basically when a player is typing it ignores any inputs binded.

ex.

local UserInputService = game:GetService('UserInputService')

UserInputService.InputBegan:Connect(function(Input, GameProcessed)
	if GameProcessed then
		return
	end
	if Input.KeyCode == Enum.KeyCode.E then
		warn(true)
	end
end)
1 Like

Thank you! This worked perfectly, much appreciated!

1 Like