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

How to make KeyBind functions not work while in the chat?

So whenever I create a KeyBind function, and I go into the chat and press the KeyBind key, the KeyBind functions start. The script that I use for a KeyBind function is:

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.R then
		--//Code Here
	end
end)

So basically, I don't want the KeyBind function to work when I'm typing in the chat.

1 answer

✓ Accepted answer

The second parameter of a InputBegan function is called GameProcessedEvent, which is only true when the coreguis (or something else, like a gui with modal) has processed the event first. Use the 2nd parameter (like processed) and you can do something similar to this: if (processedEvent) then return nil end; which says that if something else processed the key first, then do cancel everything. Red light.

Cheers.

1 comment

1

Ah, thanks! I thought someone had mentioned this kinda stuff to me once, but I ignored it. Thanks a lot!

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