To reproduce this turn on automatic chat translation and use string format on client OnIncomingMessage function: string.format("<font color='rgb(100, 225, 100)'>%s</font>", textChatMessage.Translation).
Expected behavior
Translation should appear when string is formatted.
Hi Lvie! Is this from Studio? Unfortunately, the translation field is not populated when testing inside Studio, however it should work when you test it inside a live session with another player.
Ah it looks like there’s a bug with the example code since the translation can be an empty string and not just nil when it doesn’t exist, it should be:
local TextChatService = game:GetService("TextChatService")
local FONT_COLOR = "#FF007F"
local FORMAT_STRING = `<font color='{FONT_COLOR}'>%s</font>`
local function onIncomingChatMessage(textChatMessage: TextChatMessage)
local properties = Instance.new("TextChatMessageProperties")
properties.Text = string.format(FORMAT_STRING, textChatMessage.Text)
if textChatMessage.Translation ~= nil and textChatMessage.Translation ~= "" then
properties.Translation = string.format(FORMAT_STRING, textChatMessage.Translation)
end
return properties
end
TextChatService.OnIncomingMessage = onIncomingChatMessage
I’ll put in an update to the docs to reflect this. Let me know if this fix resolves your problem!