How to add a richtext markup to concatenated text?

game.ReplicatedStorage.RecieveChat.OnClientEvent:Connect(function(msg, visibility, plrname)
    local chat = game.ReplicatedStorage:WaitForChild("Chat"):Clone()
    
    if visibility == true then
        chat.Msg.Text = "<font color=rgb(78,159,223)>"..plrname.." [TEAM]: </font> "..msg
    else
        chat.Msg.Text = "<font color=rgb(78,159,223)>"..plrname.." [ALL]: </font> "..msg
    end
    
    chat.Parent = ChatFrame.MakinChat
    
end)

why is the “plrname” variable not getting the color assigned? the “[TEAM]:” is also not getting it.

2 Likes


Here is what it looks like ingame.

is msg RichText property enabled

Yes, I checked 2 times. -------------

ok try

 if visibility == true then
        chat.Msg.Text = "<font color=#4e9fdf>"..plrname.." [TEAM]: </font> "..msg
    else
        chat.Msg.Text = "<font color=#4e9fdf>"..plrname.." [ALL]: </font> "..msg
    end

if visibility == true then
        chat.Msg.Text = [[<font color="#4e9fdf">]]..plrname..[[[TEAM]: </font>]] ..msg
    else
      chat.Msg.Text = [[<font color="#4e9fdf">]]..plrname..[[[TEAM]: </font>]] ..msg
end

I quickly made this so this could have errors let me know if it does

game.ReplicatedStorage.RecieveChat.OnClientEvent:Connect(function(msg, visibility, plrname)
    local chat = game.ReplicatedStorage:WaitForChild("Chat"):Clone()
    
    local formattedMsg = ""
    
    if visibility == true then
        formattedMsg = string.format('<font color="rgb(78,159,223)">%s [TEAM]: </font> %s', plrname, msg)
    else
        formattedMsg = string.format('<font color="rgb(78,159,223)">%s [ALL]: </font> %s', plrname, msg)
    end
    
    chat.Msg.RichText = true
    chat.Msg.Text = formattedMsg
    chat.Parent = ChatFrame.MakinChat
end)

thanks! this really helped. 3eeee

No problem i hope it fixed the issue

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.