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:
script.Parent.MouseButton1Click:Connect(function()
game:GetService("StarterGui"):SetCoreGuiEnabled("Chat", false)
end)
Thanks!
A better way to the code you’ve provided as an example would be
local enableChat = false
script.Parent.MouseButton1Click:Connect(function()
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, enableChat)
enableChat = not enableChat
end)
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)
3 Likes