How to link a custom chat UI to the chat toggle button in the TopBar?

I am making a custom chat system and I was wondering if there was an event or way to see whether someone has toggled the chat on or off using roblox’s chat toggle button? (shown below)
Screen Shot 2020-04-16 at 8.46.21 PM

Unfortunately Roblox does not allow the access of CoreGui unless using their “sandbox” on what to modify via StarterGui::SetCore and StarterGui::SetCoreGuiEnabled. So you are going to have to make your own toggle button since there is no way to listen for the chat toggle button being clicked.

Are you sure? Unlike the Leaderboard or Backpack UIs, the Chat gui isn’t a part of CoreGui but rather PlayerGui itself. Also when forking the chat, you have access to all of the client chat scripts which must be hooked to roblox’s toggle button somehow. To my understanding, the only part of the CoreGui that Chat is a part of is the toggle button itself.

I realize the Chat is in PlayerGui. The frame itself that is. Since the button is in CoreGui you won’t be able to access it, and there is no API for listening to its clicks.

This doesn’t make sense, how do the LocalScripts in Chat toggle the GUI based on that button then? There must be some way that the scripts are able to know when a player clicks this button because it’s definitely not through magic or mind reading.

I am reading through the chat scripts and I do not find anything about this button. You may have this the other way around. Perhaps core scripts in CoreGui for the button toggle the chat in PlayerGui.

After some digging around, It turns out that at the top of the roblox “ChatScript”, there is a DoEverything() function that sets up all of the events and functions for the client side of the chat system.

Inside this function, there is another function called ConnectEvent that is fired in multiple places. One time this is called is when the ChatScript does ConnectEvent("ToggleVisibility") inside the DoEverything() function. If you parent the BindableEvents created by the ConnectEvent function to ReplicatedStorage, they remain functional and you are able to hook your own events to them.

The event called ToggleVisibility is the one that is fired by CoreGui when the player decides to toggle chat using Roblox’s button, so you can simply parent this to ReplicatedStorage and hook your own events to react accordingly.

2 Likes