UI getting Auto Toggled

,
local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.K then
		script.Parent.Visible = not script.Parent.Visible
	end
end)

This is the script I use to toggle a UI frame, so when you press K, it toggles.

The problem is that I am now using TextChatService, and when I type in chat, the UI toggles. How do I fix this?

Any help would be really appreciated.

sorry my mistake haha

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.K and not gameProcessed then
script.Parent.Visible = not script.Parent.Visible
end
end)

thats better