New Experience Controls Chat Button has unannounced breaking changes

Before the new experience controls chat button, the below code used to work fine with making the chat capable of closing and opening.

-- // THE CORES*** FOR ROBLOX CORES***
starter_gui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
-- Create the Bindable objects
local ChatConnections = {}

local function AddObjects(bindableClass,targetName,...)
	-- Adds bindable events/functions to allow some coregui magic.
	local target = ChatConnections[targetName]
	if not target then
		target = {}
		ChatConnections[targetName] = target
	end
	local names = {...}
	for _,name in names do
		local signal = Instance.new(bindableClass)
		signal.Name = targetName .. "_" .. name
		signal.Parent = script
		target[name] = signal
	end
end

AddObjects("BindableEvent","ChatWindow",
	---------------------------
	-- Fired from the CoreGui
	---------------------------
	"ToggleVisibility", -- Fired when the CoreGui chat button is pressed.
	"SetVisible", -- Fired when the CoreGui wants to directly change the visibility state of the chat window.
	"FocusChatBar", -- Fired when the CoreGui wants to capture the Chatbar's Focus.
	"TopbarEnabledChanged", -- Fired when the visibility of the Topbar is changed.
	"SpecialKeyPressed", -- Fired when the reserved ChatHotkey is pressed.
	"CoreGuiEnabled", -- Fired when a user changes the SetCoreGuiEnabled state of the Chat Gui.

	---------------------------
	-- Fired to the CoreGui
	---------------------------
	"ChatBarFocusChanged",
	-- ^ Fire this with 'true' when you want to assure the CoreGui that the ChatBar is being focused on.

	"VisibilityStateChanged",
	-- ^ Fire this with 'true' when the user shows or hides the chat.

	"MessagesChanged",
	-- ^ Fire this with a number to change the number of messages that have been recorded by the chat window.
	--   If the CoreGui thinks the chat window isn't visible, it will display the recorded difference between
	--   the number of messages that was displayed when it was visible, and the number you supply.

	"MessagePosted"
	-- ^ Fire this to make the player directly chat under Roblox's C++ API.
	--	 This will fire the LocalPlayer's Chatted event.
	--   Please only fire this on the player's behalf. If you attempt to spoof a player's chat
	--   to get them in trouble, you could face serious moderation action.
)

AddObjects("BindableFunction","ChatWindow",
	"IsFocused" -- This will be invoked by the CoreGui when it wants to check if the chat window is active.
)

-- Connect ChatConnections to the CoreGui.
local tries = 0
local maxAttempts = 10

while (tries < maxAttempts) do
	local success,result = pcall(function ()
		starter_gui:SetCore("CoreGuiChatConnections",ChatConnections)
	end)
	if success then
		break
	else
		tries += 1
		if tries == maxAttempts then
			error("Error calling SetCore CoreGuiChatConnections: " .. result)
		else
			task.wait()
		end
	end
end

ChatConnections.ChatWindow.ToggleVisibility.Event:Connect(function()
	chat_gui.Enabled = not chat_gui.Enabled
	ChatConnections.ChatWindow.VisibilityStateChanged:Fire(chat_gui.Enabled)
end)

chat_gui:GetPropertyChangedSignal("Enabled"):Connect(function(...: any) 
	ChatConnections.ChatWindow.VisibilityStateChanged:Fire(chat_gui.Enabled)
end)

userInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean) 
	if input.KeyCode == Enum.KeyCode.Slash and chat_bar:IsFocused() == false and gameProcessedEvent == false then
		task.wait()
		chat_bar:CaptureFocus()
		chat_gui.Enabled = true
	end
end)

--! CHAT MOBILE FIXES
if isMobileDevice() == true then
	print("Chat - Mobile device detected!")
	main_frame.Size = UDim2.new(main_frame.Size.X.Scale, 75, main_frame.Size.Y.Scale, 75)
end
task.wait(1.5) -- we wait because roblox is slow
ChatConnections.ChatWindow.VisibilityStateChanged:Fire(chat_gui.Enabled)

But right after the update that rolled out the new behavior for the chat button, the ToggleVisibility event stopped firing. This is a breaking change and should have been documented or replaced by something more visible in documentation.

Expected behavior

I expect this pre-existing code to simply work as it should with no need to change, or at least a documentation change or announcement to say that new code is to be used should have been said.

1 Like