How do I disable DisplayNames in the new TextChatService?

I would like to have people’s real username pop up in chat when they type but I cannot seem to find a setting to disable DisplayNames in chat.
Example
I have tried to remove DisplayNames from the player’s character’s Humanoid but that does not affect the chat.

2 Likes
  1. Stick a Humanoid inside StarterPlayer
  2. Name it “StarterHumanoid”
  3. Set its “DisplayName” to an empty string

no scripting required :slight_smile:

1 Like

I just tried this and it did not work, it still shows my display name in chat.

Have you checked the ChatSettings module in the Chat service? There should be a setting called “PlayerDisplayNamesEnabled” in it. Setting it to false will use usernames instead of display names in the chat.

You can find the module by testing the game in Studio then going to Chat > ClientChatModules > ChatSettings. You only need to copy the folder itself and the ChatSettings module. Then you can stop the game and paste them back into the Chat service to make your changes.

The new chat is a different service, so there is no chat module.

Oh, sorry about that. I haven’t been on Studio for a while. Let me check that and see if I can find a solution.

Edit:

tl;dr - Roblox really limited customization on the new chat by not providing its code so I don’t have any easy solution. Sorry.

I might still just be getting used to the new chat but it seems like they really limited the chat by sacrificing full customization for convenience. There doesn’t seem to be any accessible code of the chat to modify, only options and APIs. Plus they moved the new chat GUI from the player’s PlayerGui to CoreGui so you can’t even modify the GUI itself.

Currently, the only workarounds I can think of are to just use the old chat or to make a custom chat GUI that looks very similar to the new one, add some of your own code to it, then connect it to the relevant APIs.

You can check the messages by modifying the TextChatMessages given by TextChatService.MessageReceived and TextChatService.SendingMessage

old post

This is some sample code I wrote to do just that.

-- this is on the client
local PlayersService = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")

local localPlayer = PlayersService.LocalPlayer

-- hook functions
local function onMessageReceived(textChatMessage: TextChatMessage)
	local textSource = textChatMessage.TextSource
	local chattingPlayer = if textSource
		then PlayersService:GetPlayerByUserId(textSource.UserId)
		else nil

	if chattingPlayer then
		textChatMessage.PrefixText = chattingPlayer.Name
	end
end
local function onSendingMessage(textChatMessage: TextChatMessage)
	textChatMessage.PrefixText = localPlayer.Name
end

-- connect to events
TextChatService.MessageReceived:Connect(onMessageReceived)
TextChatService.SendingMessage:Connect(onSendingMessage)

The only problem is that the TextLabels in chat will be white now. That is because the module used for computing colors does not automatically compute every change made to the message. The exact module used in the new chat cannot be used by devs because it is in CorePackages, however you could fork the one from the legacy system. The TextLabels on the new chat support RichText which makes this possible to do.

EDIT:
I found another way of keeping the username by using gsub. This will also preserve the color of the player’s name unlike my last method:

-- this is on the client
local PlayersService = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")

local localPlayer = PlayersService.LocalPlayer

-- hook functions
local function onMessageReceived(textChatMessage: TextChatMessage)
	local textSource = textChatMessage.TextSource
	local chattingPlayer = if textSource
		then PlayersService:GetPlayerByUserId(textSource.UserId)
		else nil

	if chattingPlayer then
		textChatMessage.PrefixText = (textChatMessage.PrefixText:gsub(chattingPlayer.DisplayName, chattingPlayer.Name))
	end
end
local function onSendingMessage(textChatMessage: TextChatMessage)
	textChatMessage.PrefixText = (textChatMessage.PrefixText:gsub(localPlayer.DisplayName, localPlayer.Name))
end

-- connect to events
TextChatService.MessageReceived:Connect(onMessageReceived)
TextChatService.SendingMessage:Connect(onSendingMessage)
4 Likes

I’ll try it out, if it works I’ll mark you as the solution!
Edit: I tried it out, it work’s thank you!

Where do I put this local script at?