Detect when the chat toggle button is pressed

I am trying to make a custom chat gui using the new TextChatService system.

I’ve noticed that when I disable the chat bar and window, the toggle button at the top of the screen stays there.
image
(Not sure why my Studio has the old UI)

This would be really useful, as I will not need to make my own, however, I am not sure how I can detect when this button is clicked. Does anyone have any ideas as to how I can?

1 Like

Something like this should work:

local SG = game:GetService("StarterGui")

local event = Instance.new("BindableEvent")

local tries = 10

for _ = 1, tries do
	local success = pcall(SG.SetCore, SG, "CoreGuiChatConnections", {ChatWindow = {ToggleVisibility = event}})
	if success then break end
	task.wait()
end

event.Event:Connect(function()
	print("Chat button pressed")
end)
1 Like

Thanks mate. Just tested it and it works as you said :+1:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.