What do you want to achieve? Keep it simple and clear!
I want to disable trigger while chat is open
What is the issue? Include screenshots / videos if possible!
None
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
None
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local UIS = game:GetService("UserInputService")
local Button = Enum.KeyCode.Space
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Button then
print("Spacebar")
end
end)
If you want to disable the spacebar when typing in the chat, use the second argument of Input Began called gameProcessedEvent. This is how it would look.
local UIS = game:GetService("UserInputService")
local Button = Enum.KeyCode.Space
UIS.InputBegan:Connect(function(input, gpe)
if input.KeyCode == Button and not gpe then
print("Spacebar")
end
end)
GPE stands for Game processed event, which basically includes all input related to typing in the chat rather than to execute an action in the game. For example, my game may have when I press “R” it reloads my weapon. However, when I am typing in the chat, I don’t want my weapon to reload every time I type a word with the letter “R”. Thus, ensuring that the input is not a game processed event ensures I only reload when I am not typing in chat.