When chatting, the chat shows the player’s display name along with their message. However, my goal is to display the player’s username instead of their display name.
Unlike LegacyChatService, I cannot fork scripts made by the service itself. In the old version of chat, there is an option to disable display names within the scripts.
Is there any way to disable display names in the new TextChatService? I’ve skimmed through its properties and have found no option to disable it.
1 Like
Unfortunately for us, Roblox didn’t add this as a toggle, so we’ll have to intercept every incoming message and replace it before it’s actually sent. We can do this with the TextChatService
service and the OnIncomingMessage
event.
game:GetService("TextChatService").OnIncomingMessage = function(message: TextChatMessage)
local properties = Instance.new("TextChatMessageProperties")
if message.TextSource then
local player = game.Players:GetPlayerByUserId(message.TextSource.UserId)
if player then
properties.PrefixText = `{player.Name}:`
end
end
return properties
end
Using the new TextChatService
, this code, whilst in a LocalScript inside StarterPlayerScripts
will switch it from kie
to kielikescats
in my instance. Hope this helps!
1 Like