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

How ( in my custom chat GUI ) can I make the colors of the text random?

Asked 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").ScreenGui.Frame)
            newchatline = Instance.new("TextLabel",v:WaitForChild("PlayerGui").ScreenGui.Frame)
            newchatline.Text = player.Name.. ": " ..msg
            newchatline.Size = UDim2.new(1,0,0,15)
            newchatline.Position = UDim2.new(0,0,1,-15)
            newchatline.Font = "SourceSansBold"
            newchatline.TextColor3 = Color3.new(1,1,1)
            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").ScreenGui.Frame)
        newchatline:Clone().Parent = game:GetService("StarterGui").ScreenGui.Frame
    end)
end)

Where it says Color3.new how can I make the color a random color? Do I do something like Color3.new = Color3.random or something else?

2 answers

Log in to vote
0
Answered by 10 years ago

local color = BrickColor.Random().Color

OR

local color = Color3.new(math.random(),math.random(),math.random())

either should work, with the later being more random with a wider range of possibility.

0
It made all of them blue but on the line do I put newchatline.TextColor3 = color? That's what I put or do I put. But do I put something different? coldice231 45 — 10y
0
That should be correct, you may need to try doing math.randomseed(tick()) every time a newchatline is created. ColdSmoke 55 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

You could use something line:

local color = BrickColor.Random()
local realcolor = color.Color -- Realcolor is now a Color3 value.
0
Okay I'll add it and see if it works. coldice231 45 — 10y
0
So I would put Color3.new = color? coldice231 45 — 10y
0
I still don't really understand. coldice231 45 — 10y

Answer this question