For my game I have a ui which needs multicolor text, I figured that out, but the problem is, when trying to use RichText i can’t figure out how to use font color in a script, i’ve tried like 50 different scripts but it doesn’t work.
(I basically want to be able to do: ‘blue red green’ in a script, with each word being respective to its color, but idk how to do it)
Can i have some help?
thanks in advance
(PS it would be helpful if you actually gave me some help)
What I’d do is that I’d make a variable name for each text
local Start, Middle, End
Start being the font special tag type and end being the finished font special tag while the middle is the message that you’d want here’s the example of what I did in my game.
local TextLabel = "TEXT HERE"
local PreviousMessage = "" -- So you can add in the previous message
function WriteMessageTyper(Start, Text, End) -- Weird name
if Start == "Reset" then -- Optional but I'd use it for resetting text.
PreviousMessage = ""
TextLabel.Text = ""
return
end
for i = 1, #Text do
TextLabel.Text = PreviousMessage .. (Start ~= nil and Start or "") .. string.sub(Text, 1, i) .. (End ~= nil and End or "")
wait()
end
PreviousMessage = TextLabel.Text
end
-- Result to see if it works.
wait(2)
WriteMessageTyper('<font color= "rgb(240, 40, 10)">', "RED Text", "</font>")
wait(2)
WriteMessageTyper('<font color= "rgb(225, 255, 10)">', "epic yellowish yextt", "</font>")
WriteMessageTyper('<font color= "rgb(25, 255, 0)">', "epic green!! yextt", "</font>")
WriteMessageTyper('<font color= "rgb(255, 255, 255)">', "back to boring white", "</font>")
wait(3)
WriteMessageTyper("Reset")
WriteMessageTyper('<font color= "rgb(255, 255, 255)">', "back to boring white", "</font>")