Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

A persons name is a color in a custom chat?

Asked by 10 years ago

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)
0
What color do you want it to be? A random color? TheGuyWithAShortName 673 — 10y
0
Like say I want my name to be Red and your name to be Blue. I want colors to certain people on ROBLOX EmperorF 0 — 10y

3 answers

Log in to vote
0
Answered by 10 years ago

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.

0
I just want the name to be a color EmperorF 0 — 10y
0
The code that I added should function. Articulating 1335 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
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.

0
Mk, I'll try it tommorrow to see if it works. Thanks a lot you helped me a ton EmperorF 0 — 10y
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. Articulating 1335 — 10y
Log in to vote
-1
Answered by 10 years ago

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

Answer this question