Help with Rich Text!

Hello, how can I make Only numbers bold, but letters stay normal in my given string?
I want a script auto detect whether a character is a number, and if it is a number it will be bold.
Goal example:
“hello 123

local String = "hello 123"

script.Parent.Text = String -- Help me make Only numbers bold in the whole text with an auto number detector script.

You earned <b>10</b> coins.

Result:
You earned 10 coins.

I want a script auto detect whether a character is a number, and if it is a number it will be bold.

local String = "You earned 10 coins."
local numbersinstring = string.gsub(String, "%D", " ")
script.Parent.Text = "<b>"..numbersinstring.."<b>"
2 Likes
local String = string.format("You earned <b>%d</b> coins!", Coins)

string.format would be the more preferred approach as later revisions of the string could contain multiple numbers that have either no format or are formatted differently.

local String = string.format("You earned <b>%d</b> coins in <i>%d</i> seconds!", Coins, Seconds)

Solved by Discord User: LukaDev#8725 :white_check_mark:

local String = string.gsub("hello 123", "%d+", "<b>%1</b>")

script.Parent.Text = String  --Numbers will be Bold.