Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

A persons name is a color in a custom chat?

How do you have a persons name that is a certain type of color. Below is the script!

function UpdateOldLabels(Parent)
    for i,v in pairs(Parent:GetChildren()) do
        if v.Name:sub(1,4):lower() == "line" then
            local LineNumber = v.Name:sub(5)
            if LineNumber == "12" then
                v:Destroy()
            else
                v.Name = "line"..tostring(tonumber(LineNumber) + 1)
                v.Position = v.Position - UDim2.new(0,0,0,15)
            end
        end
    end
end
 
game:GetService("Players").PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        for _,v in ipairs(game:GetService("Players"):GetChildren()) do
            UpdateOldLabels(v:WaitForChild("PlayerGui").ChatGui.Frame)
            newchatline = Instance.new("TextLabel",v:WaitForChild("PlayerGui").ChatGui.Frame)
            newchatline.Text = player.Name=='EmperorF' and ("[OWNER] "..player.Name.. ": " ..msg) or (player.Name.. ": " ..msg)
            newchatline.Size = UDim2.new(1,0,0,15)
            newchatline.Position = UDim2.new(0,0,1,-15)
            newchatline.Font = "SourceSansBold"
            newchatline.TextColor3 = player.TeamColor.Color
            newchatline.TextStrokeTransparency = 0
            newchatline.BackgroundTransparency = 1
            newchatline.BorderSizePixel = 0
            newchatline.FontSize = "Size14"
            newchatline.TextXAlignment = "Left"
            newchatline.TextYAlignment = "Top"
            newchatline.ClipsDescendants = true
            newchatline.Name = "line1"
        end
        UpdateOldLabels(game:GetService("StarterGui").ChatGui.Frame)
        newchatline:Clone().Parent = game:GetService("StarterGui").ChatGui.Frame
    end)
end)

2 comments

0

What color do you want it to be? A random color?

0

Like say I want my name to be Red and your name to be Blue. I want colors to certain people on ROBLOX

3 answers

You would need to adapt this script to use two TextLabels; one for the name, and one for the message. Unless you would like the message and the name to be the same colour.

function UpdateOldLabels(Parent)
    for i,v in pairs(Parent:GetChildren()) do
        if v.Name:sub(1,4):lower() == "line" then
            local LineNumber = v.Name:sub(5)
            if LineNumber == "12" then
                v:Destroy()
            else
                v.Name = "line"..tostring(tonumber(LineNumber) + 1)
                v.Position = v.Position - UDim2.new(0,0,0,15)
            end
        end
    end
end

game:GetService("Players").PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        for _,v in ipairs(game:GetService("Players"):GetChildren()) do
            UpdateOldLabels(v:WaitForChild("PlayerGui").ChatGui.Frame)
            newchatline = Instance.new("TextLabel",v:WaitForChild("PlayerGui").ChatGui.Frame)
	    newplayerline = Instance.new("TextLabel",v:WaitForChild("PlayerGui").ChatGui.Frame)
            newchatline.Text = msg
	    newplayerline.Text = player.userId == Game.CreatorId and "[OWNER] "..player.Name or player.Name
            newchatline.Size = UDim2.new(0.5,0,0,15)
	    newplayerline.Size = UDim2.new(0.5,0,0,15)
            newchatline.Position = UDim2.new(0.5,0,1,-15)
	    newplayerline.Position = UDim2.new(0,0,0,15)
            newchatline.Font = "SourceSansBold"
	    newplayerline.Font = "SourceSansBold"
            newchatline.TextColor3 = Color3.new(0,0,0) --Black message.
	    newplayerline.TextColor3 =  player.userId == Game.CreatorId and Color3.new(1,0,0)  or player.TeamColor.Color          
            newchatline.TextStrokeTransparency = 0
	    newplayerline.TextStrokeTransparency = 0
            newchatline.BackgroundTransparency = 1
            newplayerline.BackgroundTransparency = 1
            newchatline.BorderSizePixel = 0
	    newplayerline.BorderSizePixel = 0
            newchatline.FontSize = "Size14"
    	    newplayerline.FontSize = "Size14"
            newchatline.TextXAlignment = "Left"
	    newplayerline.TextXAlignment = "Left"
            newchatline.TextYAlignment = "Top"
            newplayerline.TextYAlignment = "Top"
            newchatline.ClipsDescendants = true
            newplayerline.ClipsDescendants = true
            newplayerline.Name = "line1"
            newchatline.Name = "line1"
        end
        UpdateOldLabels(game:GetService("StarterGui").ChatGui.Frame)
        newchatline:Clone().Parent = game:GetService("StarterGui").ChatGui.Frame
    end)
end)

Untested, may or may not work.

2 comments

0

I just want the name to be a color

0

The code that I added should function.

newchatline.TextColor3 = player.TeamColor.Color

Try changing that to this:

newchatline.TextColor3 = player.Name=="EmperorF" and BrickColor.new("Bright red").Color or BrickColor.new("Bright blue").Color

It's not guaranteed that this will work, but I think it will. Let me know if anything goes wrong.

2 comments

0

Mk, I'll try it tommorrow to see if it works. Thanks a lot you helped me a ton

0

This isn't what the asker was requesting. They stated that they wanted the name to be one colour and the message to be another.

Is the script in ServerScriptService? If not it needs to be in there.

This discussion is preserved as it was. New answers, comments, and votes are closed.