How Would I Make a Chat Toggle GUI?

Hi everybody! I’m making a chat toggle GUI for those in my game whom the chat is disturbing.

I already made the part where the chat turns off, but I am unsure on how to make it so when you click on it again, the chat turns back on.

Here’s my code:


game:GetService("StarterGui"):SetCoreGuiEnabled("Chat", false)



A better way to the code you’ve provided as an example would be

local enableChat = false

	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, enableChat)
	enableChat = not enableChat

This code does exactly what you did but in a much more simpler way. First we set enableChat to false, then whe nthe player clicks the TextButton, it sets The CoreGuiType Chat to be the value of enableChat, then it inverts the value of enableChat (if it was false it becomes true and vice versa)