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

How do I make a persons chat there team color?

Asked by 10 years ago

Okay so say I have this:

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.Name=="EmperorF" and BrickColor.new("Bright red").Color or BrickColor.new("Bright blue").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)

Does line 24:

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

Get changed to this?:

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

I dont know if it will work or not or if it will break down my game

3 answers

Log in to vote
0
Answered by 10 years ago
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.Name=="EmperorF" and BrickColor.new("Bright red").Color or 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)
Ad
Log in to vote
0
Answered by 10 years ago

Make sure the spawn is the same color aswell, as I've needed to change this to fix problems like this

Log in to vote
-1
Answered by 10 years ago

Step-by-step answer...

1) Get a coloured spawn

2) Go to teams

3) Change team colour in the properties

See if this works

OH AND MAKE SURE YOU DO THIS AS WELL : make sure the team colour and the team is the same:)

Answer this question