Hello, I was wondering how I could change a specific word’s color in the middle of text.
An example (I want to change common’s color):
I tried using html with richtext as chatgpt suggested but it didn’t work:
FishCaughtText.Text = 'You caught: ' .. ChosenFish .. ' (<font color=\'' .. RarityColorChosen .. '\'>' .. ChosenRarity .. '</font>).'
Enabling RichText
on the textlabel is necessary, and then the syntax is described on this page: Rich Text Markup | Documentation - Roblox Creator Hub
Two ways to set color:
I want the <font color="#FF7800">orange</font> candy.
I want the <font color="rgb(255,125,0)">orange</font> candy.
I’m not sure what format your RarityColorChosen is in, but if it’s a Color3, you can do something like this:
local ChosenRarity = "Common"
local RarityColorChosen: Color3 = Color3.fromRGB(0, 100, 200)
local colorString = `#{RarityColorChosen:ToHex()}`
FishCaughtText.Text = `You caught: {ChosenFish} (<font color="{colorString}">{ChosenRarity}</font>).`
1 Like
system
(system)
Closed
#3
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.