List of text cahnging colors

So what I’m trying to do is make a little client script editor. Just like when you make a script and type local it turns red.

The problem is that it doesn’t work when you are currently typing, only when the textbox focus is lost, other wise it will glitch out and make a really long text in the textbox.

I know how to cahnge the textcolors while the player is not currently typing, but I only know how to change one word not a whole list of words with diffrent colors like:

local wordTable = {"local" = (1,1,1), "Instance" = (1,1,1)}

the property changed signalfrom other post didn’t work, could someone help me?

1 Like

I’m assuming that by the property chabged signal, you mean a TextBox:GetPropertyChangedSignal("Text")? If that doesn’t work, try updating it after every keypress.

As for applying the colours, you can enable RichText and use HTML tags, and update the box with that text.

local colours = {
    ["local"] = {220, 0, 0}
}

local function update()
    local words = string.split(TextBox.Text, " ")
    for i, word in next, words, nil do
        if not colours[word] then continue end
        local colour = colours[word]
        words[i] = string.format(
             '<font color = "rgb(%d, %d, %d)">'..word..'</font>',
            colour[1],
            colour[2],
            colour[3]
        )
    end

    TextBox.Text = table.concat(words, " ")
end

That does work but it works really weird when you type local the text will be literly:

'<font color = "rgb(%d, %d, %d)">'local'</font>'

Did you enable RichText on the TextBox like I said? Make sure your colours also are written correctly in the table or the string won’t format.

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