i think the new update broke this method, this is the code im using:
local UserInputService = game:GetService("UserInputService")
local StarterGui = game:GetService("StarterGui")
local chatEnabled = true
local function toggleChat()
chatEnabled = not chatEnabled
StarterGui:SetCore("ChatActive", chatEnabled)
end
UserInputService.InputBegan:Connect(function(inp, gpe)
if gpe then return end
if inp.KeyCode == Enum.KeyCode.Z then
toggleChat()
end
end)