In many cases I see games using text label(s) that include various colors. One I see mostly that is inplimented into every game by default is Roblox's Chat system. In the system it has your username in one color and then your message in another. I made a chat system before using different colors but, I used Defaultio's Markup Module. He creates text labels individualy used for each letter. I want to be able to have say [b_irdio]: as one label and then Hello! as another label.
It's probably better to use a module, since there's no point in reinventing the wheel (unless you're making a better wheel)
But alas, here's the simplest way to do it:
local currentX = 0 local gui = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui) -- create a GUI function createLabel(text, color) local label = Instance.new("TextLabel") label.TextStrokeTransparency = 0 -- set appearance properties label.TextColor3 = color label.Text = text label.TextSize = 18 label.BackgroundTransparency = 1 label.Position = UDim2.new(0.5, currentX, 0.5, 0) -- position this label to be in front of the other labels label.TextXAlignment = "Left" -- align to the left, since it's easier to work with label.Parent = gui -- set parent currentX = currentX + label.TextBounds.X -- move the next labels over by the width of this text end createLabel("[b_irdio]: ", Color3.new(1, 0, 0)) createLabel("Hello!", Color3.new(1, 1, 1))
Every color variation is an additional TextLabel. TextLabels only define a single color.
Here is the core system's provision for customizing chat gui