How can I remove KeyInput when chatting?

Hello!

While developping my horror game, I made a Jumpscare admin command. Everything works fine, exept there’s one problem, one that can annoy PC users.

If for example while chatting (on PC with a keyboard) I press E (one of the Input), the action for the player pressing E runs.

TL;DR: I want to disable UserInput on PC while chatting.

Does anyone know what to do?

Thanks for reading.

You could check if UserInputService:GetFocusedTextBox() isn’t nil

1 Like

How does that work exactly? I’ll show an example of my code.

local userInputService = game:GetService("UserInputService")

userInputService.InputBegan:Connect(function(input,  gameProcessedEvent)

	if input.KeyCode == Enum.KeyCode.E then
		print("E HAS BEEN PRESSED")
    end
end)

Or is it in the chat scripts that I should do something?

GetFocusedTextBox returns a textbox instance if you are typing in a textbox. If it’s nil then there’s no focused textbox (not typing)

Alternatively, you can just use the gameProcessed event

if userInputService:GetFocusedTextBox() then return end
-- or
if gameProcessedEvent then return end
1 Like

Thanks it works! This problem was bugging me since these Inputs like E are commonly used.

Yeah, @Maximum_ADHD 's flying tool has that problem too