Here is my code, CodeBox is the textbox and I am looping through every character
local FirstHalf = string.sub(CodeBox.Text,1, i, i -1)
local SecondHalf = string.sub(CodeBox.Text,i + 2)
CodeBox.Text = FirstHalf.."<b><font color=\"rgb(115, 204, 20)\">if</font></b>"..SecondHalf
Apologies, but I’m not quite sure I understand the issue here. Are you referring to the fact that all the formatting is lost when you focus on the text box? This is intentional. When a user focuses on text boxes, they’ll be editing the original XML string and it’ll parse when focus is lost.
You can read more on the RichText release announcement under TextBox behaviour:
If this isn’t it, would be appreciated if you could clarify what’s wrong here. Tried reading the thread over a couple of times but not sure I get what is being asked.