How Do I Make The Players' Name Colors Random On A Custom Chat GUI?
I'm making a chat GUI similar to the old one, and I'm trying to figure out how to make it so the people have similar colors like on the normal chat GUI. This is what I got so far.
01 | function UpdateOldLabels(Parent) |
02 | for i,v in pairs (Parent:GetChildren()) do |
03 | if v.Name:sub( 1 , 4 ):lower() = = "line" then |
04 | local LineNumber = v.Name:sub( 5 ) |
05 | if LineNumber = = "6" then |
08 | v.Name = "line" .. tostring ( tonumber (LineNumber) + 1 ) |
09 | v.Position = v.Position - UDim 2. new( 0 , 0 , 0 , 15 ) |
15 | game:getService( "Players" ).PlayerAdded:connect( function (player) |
16 | player.Chatted:connect( function (msg) |
17 | for _,v in ipairs (game:GetService( "Players" ):GetChildren()) do |
18 | UpdateOldLabels(v:WaitForChild( "PlayerGui" ).ScreenGui.Frame) |
19 | newchatline = Instance.new( "TextLabel" ,v:WaitForChild( "PlayerGui" ).ScreenGui.Frame) |
20 | newchatline.Text = player.Name.. ": " ..msg |
21 | newchatline.Size = UDim 2. new( 1 , 0 , 0 , 15 ) |
22 | newchatline.Position = UDim 2. new( 1 , 0 , 0 - 15 ) |
23 | newchatline.Font = "Arial" |
24 | newchatline.TextColor 3 = Color 3. new( 1 , 1 , 1 ) |
25 | newchatline.TextStrokeTransparency = 0 |
26 | newchatline.BackgroundTransparency = 0.1 |
27 | newchatline.BorderSizePixel = 0 |
28 | newchatline.FontSize = "Size14" |
29 | newchatline.TextXAlignment = "Left" |
30 | newchatline.TextYAlignment = "Top" |
31 | newchatline.ClipsDescendants = true |
32 | newchatline.Name = "line1" |
34 | UpdateOldLabels(game:GetService( "StarterGui" ).ScreenGui.Frame) |
35 | newchatline:Clone().Parent = game:GetService( "StarterGui" ).ScreenGui.Frame |