#changing player chat name not working

1 messages · Page 1 of 1 (latest)

steep grove
#
local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")

task.wait(1)

TextChatService.OnIncomingMessage = function(Message)
    if Message.TextSource then
        local Player = Players:GetPlayerByUserId(Message.TextSource.UserId)
        local Character = Player.Character
        local Humanoid = Character:FindFirstChildOfClass("Humanoid")
        
        if Player.DisplayName == "John Doe" or Player.DisplayName == "Roblox" then
            Message.PrefixText = Humanoid.DisplayName .. " :"
        end
    end
end```
#

changing player chat name not working

broken radish
#

Hi, what’s not working?

steep grove
#

so sorry

#

but uhh basically, i wanna make it so that someones name changes into John Doe or Roblox depending on their Humanoid.DisplayName

#

but it only appears to one client but not all players

broken radish
#

Anyways if it happens to one client not all, it seems like the script needs to be a serverscript not localscript. If you don't know what this means, this means you need to use remoteevents to pass along the name to change to the server script, where the server will interpret that and change the text on all clients.

steep grove
#

if it can be, i wouldnt be here whining about my issue

#

TextService.OnIncomingMessage only works on client

#

also secondly, this worked in a 2 player simulation, but not in a real game

broken radish
#

Here is the code

echo solarBOT
#

studio** You are now Level 8! **studio

broken radish
#
local TextChatService = game:GetService("TextChatService")

TextChatService.OnServerReceivingMessage = function(textChatMessage)
    local speaker = textChatMessage.TextSource
    if not speaker then return end

    local player = game.Players:GetPlayerByUserId(speaker.UserId)
    if not player then return end

    if player.DisplayName == "John Doe" or player.DisplayName == "Roblox" then
        local prefix = player.DisplayName ... "" --I don't know the symbol so just put it in the string
        local newText = prefix .. textChatMessage.Text

        -- Return message as table
        return {
            Text = newText,
            Metadata = textChatMessage.Metadata,
            TextChannel = textChatMessage.TextChannel,
            PrefixText = textChatMessage.PrefixText,
            ShouldDeliver = true
        }
    end
end

Doublethumbs

steep grove
#

what the heck?

steep grove
#

that is not a thing

broken radish
#

Notice it is NOT an event so you don’t use :Connect(function())

steep grove
#

yeah, but uhh it doesnt exist for TextChatService

#

i did that exact thing

#

nothing

#

infact in sent an error that OnServerRecievingMessage doesnt exist