Making a player's roleplay name appear in chat

In some games in roblox like Super Hero Life II, Robloxian Highschool, the players’ roleplay names appear in the chat instead of their actual names like this:

image

I was wondering how i could do that in my game and make it so players’ roleplay names actually appear on the chat like that.

Thanks!

2 Likes
2 Likes

After looking for a while that did help but did not solve the problem

You need to set the extra data now, it’s kinda like making chat tags:

local ReplicatedStorage = game:GetService('ReplicatedStorage')

local changeNickname = ReplicatedStorage:WaitForChild('changeNickname')

local ChatService = require(script.Parent:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

changeNickname.OnServerEvent:Connect(function(player, nickname)
	local Speaker = ChatService:GetSpeaker(player.Name)
Speaker:SetExtraData('DisplayName', nickname)
end)
1 Like

Just a second, i’ll test it out

Ok, i made a textbox and a button for the name. This is the script i used

script.Parent.MouseButton1Click:Connect(function()
	local nickname = script.Parent.Parent.TextBox.Text
	
	game.ReplicatedStorage.Events.changeNickname:FireServer(nickname)
end)

And then for the server script i used yours

local ReplicatedStorage = game:GetService('ReplicatedStorage')

local changeNickname = ReplicatedStorage.Events:WaitForChild('changeNickname')

local ChatService = require(script.Parent:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

changeNickname.OnServerEvent:Connect(function(player, nickname)
	local Speaker = ChatService:GetSpeaker(player.Name)
	Speaker:SetExtraData('DisplayName', nickname)
end)

And yet it didn’t work

Did i do something wrong?

Did you do everything that the forum post said? It should work if you’ve done that.

I did do the modifications in the chat script

Are you getting any errors in the output?

No, but i’m pretty sure the error is in the server script, i inserted prints in both scripts and the server script didn’t print

script.Parent.MouseButton1Click:Connect(function()
	local nickname = script.Parent.Parent.TextBox.Text
	
	game.ReplicatedStorage.Events.changeNickname:FireServer(nickname)
	
	print("text is " .. nickname)
end)
local changeNickname = game.ReplicatedStorage.Events.changeNickname

local ChatService = require(script.Parent:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

changeNickname.OnServerEvent:Connect(function(player, nickname)
	print("received, text is " .. nickname)
	local Speaker = ChatService:GetSpeaker(player.Name)
	Speaker:SetExtraData('DisplayName', nickname)
	print("done")
end)

image

Is the server script in ServerScriptService?

It’s in a folder inside it. So yes

I’m 90% sure the error is in one of these two lines

local ChatService = require(script.Parent:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

changeNickname.OnServerEvent:Connect(function(player, nickname)

Well if it’s in a folder then it wouldn’t be local ChatService = require(**script.Parent**:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

It should be script.Parent.Parent in that case.

1 Like

Yep, that solved it.

Everything is working.

Thanks a lot! And sorry for not realizing that lol

1 Like