How to change color of a text?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    have “zombies left” green and the text number of zombies red
local round = game.ReplicatedStorage.Values.zombiesAlive

local rnd = script.Parent.round

function Update ()
	if round.Value == 0 then
		rnd.Text = "N O  Z O M B I E S  L E F T"
	else
		rnd.Text = "Z O M B I E S  L E F T  "..round.Value
	end
end

Update()

round.Changed:Connect(function()
	Update()
end)

I tried

rnd.Text = 'Z O M B I E S  L E F T <mark><font color="rgb(255,0,0)"'..round.Value 

but this did not work

Is there an article or reference on how to change the color of text?

This should help!

I know there’s probably a more complex but faster way to do this but normally I just create 2 text labels for 2 different colours and change them accordingly

So i looked through the article, the issue is the text i want to change is a value so when im adding in the “” it breaks or does not change the color of the value text… is there a work around for this?

You

  1. Used a random mark tag
  2. Didn’t close the font tag.

Here is the correct code (untested)

rnd.Text = `Z O M B I E S  L E F T <font color="rgb(255,0,0)">{round.Value}</font>`
1 Like

Use ‘’ inside of the “”

Limit

local round = game.ReplicatedStorage.Values.zombiesAlive

local rnd = script.Parent.round

function Update ()
	if round.Value == 0 then
		rnd.Text = "N O  Z O M B I E S  L E F T"
        rnd.TextColor = Color3.fromRGB(0, 255, 0)
	else
		rnd.Text = "Z O M B I E S  L E F T  "..tostring(round.Value)
        rnd.TextColor = Color3.fromRGB(255, 0, 0)
	end
end

Update()

round.Changed:Connect(function()
	Update()
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.