Rename Chat Speaker

Hello Developers!

Currently, I’m trying to rename a player speaker so if is in a team his name in the classic chat can be changed to Classified or to another player name.

I have a look into the forums and the chat service, but nothing really worked.

So here my problem is there any way to rename a player speaker? If so is there a function in the chat service?

1 Like

This is not possible; the chat system uses the player’s username and, to the extent of my knowledge, this cannot be changed without manually replacing the entire chat system script. The same applies for the leaderboard. However, it may be worth exploring SetCore(). You can use that to create system messages in the chat box.

1 Like

With your way, i have found a way to say messages correctly, but it’s not perfect as its a systemmessage instead of a speaker, but this will be used for the moment.

1 Like

You can change the chat speaker’s name by forking the DefaultChatMessage module (around line 24) and changing the message type of the wanted chat speaker to the forked module.

1 Like

Can you elaborate what you mean by “Forking”? I’m unsure of what you mean, and I’m confident neither does @Trystanus.
Furthermore, to my understanding, the DefaultChatMessage module you speak of is instantiated during runtime, making editing it during editing mode impossible.
I understand there’s some way of getting and editing a function of a script in runtime, otherwise all of these “script fighting” places wouldn’t exist. Do you think you could explain in further detail?

Thanks,
CyroStorms

Please refer to the Lua Chat System API documentation, specifically Message Creator Modules section.

You can edit the module by playing in solo mode and copying the module. And then pasting it inside chat service will overwrite the old module as far as I know

1 Like

I fixed this issue in a system fork that I made for nicknames. To ‘rename’ a ChatSpeaker, you’ll want to set some extra data called ‘DisplayName’.

You’ll need to fork the following scripts:

  • DefaultChatMessage

(to fork the chat system, run the game and copy all the items in game.Chat, stop the game and paste it back into game.Chat)

Find the line that contains

local formatUseName = string.format("[%s]:", fromSpeaker)

and replace it with

local formatUseName
if extraData.DisplayName then --check if the user has a custom name
	formatUseName = string.format("[%s]:", extraData.DisplayName) --set the name format to it
else
	formatUseName = string.format("[%s]:", fromSpeaker) --else use their player name
end

Finally, set the extra data “DisplayName” and the name will appear in chat

16 Likes

Im going to currently try this, as its seem as a better option then making full edit to the script.

This work now really well!

@ProspektNova I had a problem with you solution just because I put DefaultChatMessage module in the wrong folder, as for @FilteredDev your function gonna make it a lot more easy to edit then just lake function inside the module!

2 Likes

Hey! I hope you reply to this what do you mean by “Finally, set the extra data “DisplayName” and the name will appear in chat” I am trying to give my players custom names, How would I set their custom name to this?