How to get rid of "Your message could not be sent" error message with TextChatService?

I have a script that changes the colors of certain words in chat messages. Is there any way to prevent this error message from showing up in the chat when someone’s text is edited?

Screenshot (1217)

here’s my current script:

local TextChatService = game:GetService("TextChatService")
local rbxGeneralChannel: TextChannel = TextChatService:WaitForChild("TextChannels"):WaitForChild("RBXGeneral")

if not game.Players.LocalPlayer.Character then
	game.Players.LocalPlayer.CharacterAdded:Wait()
end
task.wait(1)

rbxGeneralChannel.OnIncomingMessage = function(textChatMessage)
	local textChatMsgProperties = Instance.new("TextChatMessageProperties")
	
	if string.find(string.lower(textChatMessage.Text), "house") then
		local substart = string.find(string.lower(textChatMessage.Text), "house")
		local subend = substart + #"house"
		
		textChatMessage.Text = string.sub(textChatMessage.Text, 1, substart-1)..'<font color="#6570ae">'..string.sub(textChatMessage.Text, substart, subend)..'</font>'..string.sub(textChatMessage.Text, subend+1, -1)
	end
	return textChatMsgProperties
end

3 Likes

figured it out. Directly editing textChatMessage’s text instead of textChatMsgProperties text was the problem

1 Like