Problem with html, in roblox

local coinValue = ld.Coins.Value

local function updateTimeCoin()
	local months = math.floor(coinValue / (30 * 24 * 3600))
	local days = math.floor((coinValue % (30 * 24 * 3600)) / (24 * 3600))
	local hours = math.floor((coinValue % (24 * 3600)) / 3600)
	local minutes = math.floor((coinValue % 3600) / 60)
	local seconds = coinValue % 60

	local formattedTime = string.format("<font color='rgb(0,255,0)'>M %02d,</font> <font color='255,255,255'>D %02d,</font> <font color='255,255,255'>H %02d,</font> <font color='255,255,255'>M %02d,</font> <font color='255,255,255'>S %02d</font>", months, days, hours, minutes, seconds)
	
	gui.TimeCounterLetters.RichText = true
	gui.TimeCounterLetters.Text = formattedTime
	
	print("Months:", months)
	print("Days:", days)
	print("Hours:", hours)
	print("Minutes:", minutes)
	print("Seconds:", seconds)
end

updateTimeCoin()

I want the result to be like this:
Снимок экрана 2024-05-02 в 14.14.54

But for some reason, I’m like this so far:

Question, what am I doing wrong?

I have RichText


what have you done to my text label ;-;


Anyway:

The issue is that you didn’t add rgb() to 4 of the 5 colour assignments, clearer seen when the text is seperated over multiple lines:

<font color='rgb(0,255,0)'>M %02d,</font> 
<font color='255,255,255'>D %02d,</font> 
<font color='255,255,255'>H %02d,</font> 
<font color='255,255,255'>M %02d,</font> 
<font color='255,255,255'>S %02d</font>

Add rgb() to each of them and it should work!


(Also, it’ll be clearer to others to refer to it as RichText in the title, as while it is a markup language, it is not HTML)

3 Likes

(If my post above worked for you, make sure to mark it as the solution. If it didn’t work, let us know so that we can provide additional help)

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