When someone types n in chat it fires this script
game:GetService("UserInputService").InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.N then local statsGui = script.Parent.StatsBorder local invGui = script.Parent.Parent.InventoryGuiBG.InventoryBorder if statsGui.Visible == true then statsGui.Visible = false elseif statsGui.Visible == false then invGui.Visible = false statsGui.Visible = true end end end)
How can I tell if a player is focused on a textbox or not?
The UserInputService has a function called GetFocusedTextBox
that returns the current focused TextBox. If no TextBox is focused, it returns nil. So you can use it in your script to not allow firing the function if a TextBox is being focused.
So your code should look like this:
local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:connect(function(input) if not UserInputService:GetFocusedTextBox() then if input.KeyCode == Enum.KeyCode.N then local statsGui = script.Parent.StatsBorder local invGui = script.Parent.Parent.InventoryGuiBG.InventoryBorder if statsGui.Visible == true then statsGui.Visible = false elseif statsGui.Visible == false then invGui.Visible = false statsGui.Visible = true end end end end)