TextChatService issues

So, I’ve been having some issues with TextChatService. Normally, I’d go the regular documentation way, verifying gamepasses on the client and appending the tag on the client itself utilizing the OnIncomingMessage features. However, I’ve started to toy with not trusting the client and maximizing server usage and computation.

What I’ve tried to do so far is attach message metadata and modify the PrefixText itself, but neither seem to be replicating to the client (I’m using :SendingMessage:Connect() on the Server and .OnIncomingMessage = function() on the client) in the way I expected.
I’d try RemoteEvents, but I’m not sure how they’d work in a server full of 24 individuals, especially under large stress tests.
image
I’ve been getting this upon modifying PrefixText on the server
example here:

TextChatService.SendingMessage:Connect(function(message: TextChatMessage)
	local src = if message.TextSource then message.TextSource else nil
	local id = if src.UserId then src.UserId else nil
	local tag = if Stubs[id] then Stubs[id] else nil -- this ternary statement will have other logic too but for right now there are no products LOL
	
	local props = Instance.new("TextChatMessageProperties") -->> ignore this, btw
	
	message.Metadata = HttpService:JSONEncode({Tag = "AAAAAA"})
	
	message.PrefixText = "AAAAA"
	
	return message
	
end)

and attempting to retrieve it on client, shown here:

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
	local plr = message.TextSource
	if not plr then 
		return
	end
	local ok, md = pcall(function()
		return HttpService:JSONDecode(message.Metadata) -->> i removed the metadata check, it returns nil anyway.
	end)
	print(message.PrefixText)
end

and it really doesn’t seem to behave how I expect it. I’ve looked at the documentation, but it doesn’t really help me much.

Does anyone have any knowledge on the inner workings of TextChatService so I could even begin to figure this out - or at least help me figure out what workarounds I may need to do to achieve this? That’d be greatly helpful, because I… frankly am at a little bit of a loss.

Sorry if this is a bit of a weird post, it’s 35 past midnight right now. Brain’s a bit fried.

1 Like

You can not try to secure Prefixes on server. Exploiter anyways can give a prefix himself but it will be visible only in his chat and other clients will see only real nametags(unless they all are exploiters).

Hey there, what are you trying to achieve in this thread, it’s kind of a little all over the place right now. Could you reword it a bit?

Essentially I’m trying to do all prefix verifying and modification of message PrefixText on the server.

*ideally

I’m afraid the only answer I can really give at the moment is that Roblox’s new chat system isn’t built in the way you might want to achieve this. Roblox intentionally designed the new chat system with client local rendering in mind, so that everything chat related would be handled for each specific client individually.

I don’t think Roblox allows your own chat system anymore either, so normally I’d give that option, but I don’t think it’s available anymore, even using Roblox’s filter system (weird, I know).

What I personally do and I believe everyone does is have the client read OnIncomingMessage and modify the prefix there, as Hazelnut mentioned above, this should only modify the client’s chat and wont have it replicated on anyone elses client. Once a message is sent, OnIncomingMessage is read on every client, so it should be fine.

If you need a little help with that, I don’t mind helping, otherwise I don’t think what you want to achieve is possible on the server-side.

1 Like

That’s what I figured. I’ve always done OnIncomingMessage but just wanted to test. That’s fine. That should not be an issue, then. Thanks!

Glad I could be of help in some sort of way, hopefully Roblox does allow custom chat systems again because personally I don’t see a problem if you use Roblox filter, but not sure where their minds may be at right now, probably something they know internally that we don’t :person_shrugging: ?