Lets Say i have a StringValue and that string is a text on one of my guis, If i wanted to change the Color of “T” or “x” letter of the “Text” String Which is inside a TextLabel, How would i do that?
(Note: The given Text will be a random Text, so i can’t change it manually.)
Sorry That i couldn’t explain it as good as i thought, but yeah any help will be appreciated
The String would be loaded into a TextLabel.
The TextLabel has properties assigned to it as a whole.
I don’t believe you can assign properties to the individual characters within the TextLabel.
use string.gsub
local sub, rep = string.gsub(String, CharacterToReplace, Replacement)
For Example:
local str = "Text"
local sub, rep = string.gsub(str, "T", "x")
print(sub) --> xext (the substring)
print(rep) --> 1 (The amount of characters that were replaced)
How does this script change the color of an individual character in the TextLabel?
Ah, good to know.
I remember seeing RichText but never looked into it.
if you know how to do it, could you explain a little?
im trying to get the string inside a StringValue (Thers a text inside a text label which comes from that string valuel) and change the color of the letter i want.
is it possible? if so, how can i accomplish it…
pretty sure this is how you would color the letter ‘T’
local Colored_Text = "<font color='rgb(255,0,0)'>T</font>ext" -- T is now red
local TextLabel = script.Parent
TextLabel.RichText = true
TextLabel.Text = Colored_Text
the documentation gives plenty of examples
As i have stated Above, the “T” Was just an example, the actual text will be random