TextChatService relies on client?

Hey everyone!

When using the TextChatService, OnIncomingMessage can only be used on Client side…
If I want to add tags to players, but, control that from server what approach should I use?

Maybe a RemoteFunction?
(this doesnt add extra lag to the chat?)

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
	local properties = Instance.new("TextChatMessageProperties")

	if message.TextSource then
		local player = Players:GetPlayerByUserId(message.TextSource.UserId)
		if player then
			local isTag = RemoteFunction:InvokeServer()
			if isTag then
				properties.PrefixText = "<font color='#F5CD30'>"..tostring(isTag).."</font> " .. message.PrefixText
			end
		end
	end

	return properties
end

Theres no way to catch the player chatting in Server side like with the legacy chat?
player.Chatted:Connect(function())

1 Like

use TextChatService:RegisterChatCallback

Chat:RegisterChatCallback(Enum.ChatCallbackType.OnServerReceivingMessage, function(message)
	return message
end)
1 Like

Thank you so much, Im gonna research, but could you pls elaborate on how to use it?

This may be of use: Chat:RegisterChatCallback() | Roblox Creator Documentation

But how to use it along with TextChatService?

I believe you can set the message’s prefix text just like in the properties.

Chat:RegisterChatCallback(Enum.ChatCallbackType.OnServerReceivingMessage, function(message)
	local isTag = --whatever
	if isTag then
		message.PrefixText = "<font color='#F5CD30'>"..tostring(isTag).."</font> " .. message.PrefixText
	end
	return message
end)

Honestly I never used these CallBacks before, how should I make them to trigger when using the TextChatService? I believe those CallBacks only works when using ChatService and not TextChatService, but idk

Ah, yes, it uses ChatService, my fault. After looking through TextChatService, it seems OnIncomingMessage works on the server, or at least it should. Since they didn’t specify whether or not it was on the client or the server, I’m assuming it’s on both. Try doing this again on the server instead.
Reference - TextChatService | Roblox Creator Documentation

Yup thats the first thing I tried, and the error in output is that OnIncomingMessage can only be implemented from client and not server

Well, then the best ways here are to have the server send the tags of players to the client each time a tag is changed/added and have the client store that variable or have a value of the tag under the player so you can change it through that. Other than those ways, there’s not much you can do.

Yeah, but anyone that changes their client script will have any Tag they want… (exploiters)
The best solution I think is the one I mentioned in my original post, use a RemoteFunction to get the proper Tag to use… but still, anyone can delete that client script and exploit the TextChatService as they want to… cause it relies on client… which is a very bad idea according to me… legacy chat is better…

Well, the changed tag will only show for themselves. Either way, the exploiter can change any variable they want, so it’s not like using a remote function will change the fact that they can change the tag.

As far as I understand, the new TextChatService uses client scripts to decide what to show on chat GUI… If not… Whats the purpose of the Tags if nobody will be able to see it and only the client?

No no, you are misunderstanding me. I am saying that if they try to change their tag, only the exploiter themselves will see that changed tag. Each client will determine what the tag should be based on the value.

1 Like

Sorry, this new TextChatService is pretty confusing to me, I meant, by injecting a client script using the OnIncomingMessage everyone in server will see whatever the exploiter choosed as tag, color etc

That’s not possible, exploiters cannot actually forcibly replicate anything (except positions and velocities of specific physics objects… but that’s not relevant here).

As Kaiden said, it’ll only change for the exploiter, not for anyone else.

1 Like

OnIncomingMessage is purely client sided. It doesn’t affect other players. Since the client is editing a received message, they are editing what will be shown in their chat. Injecting an OnIncomingMessage isn’t going to suddenly hop server-client boundaries and change what other people see.

1 Like

Then, the only way I found to add a Tag to chat for a player, according with the documentation is by a client script, like this:

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
	local properties = Instance.new("TextChatMessageProperties")
	if message.TextSource then
		local player = Players:GetPlayerByUserId(message.TextSource.UserId)
		if player then
			properties.PrefixText = "<font color='#F5CD30'>[VIP]</font>".."<font color='#F5CDF0'> "..message.PrefixText.."</font>"
			properties.Text = "<font color='#F5CD30'>"..message.Text.."</font>"
		end
	end
	return properties
end

I dont see any other way to add a Tag to chat for the player. If that doesnt replicate for others while using the TextChatService, then that Tag will not be seen by others, making useless to even have a tag if only the client itself can see it

You are still misunderstanding us. If an exploiter changes the tag, only the exploiter will see the changed tag. All of the other clients will still see the tag as the non-changed tag.

1 Like

Sorry, I understand the boundaries of client and not replication, everything changed on client side will not replicate, thats great. But understand my point and my confusion about this.
The only way to add a tag when using TextChatService is by a client script, means that client script when using the new chat service would replicate, if it doesnt, how other players could see the tag?