Changing Text Color in a StringValue

Hello

  1. What do you want to achieve? I want to change my text color from black to white

  2. What is the issue? I cannot change it, there are no properties to edit

  3. What solutions have you tried so far? I didnt see anything, unless I have missed something, tell me if i have

The stringvalue is in a folder in replicated storage

Tell me if you want to see code

code

thank you

Have you tried using Attributes? Go to the property page, scroll to the bottom, and click add attribute. Then set it to color3.

If you don’t want to use attributes, can I see your script?

No, it’s impossible to change the Color3 of a string value, but you can use rich text (enable rich text in your text label!)

So set their value to something like <font color="rgb(255,0,0)">ok</font>

What do you mean? do I put that in the script?

Oh, I would like to try attributes
Done, now what do I do next?

No, that would be the string value’s value.

text is still black here, the text is using the value property already

Can you show me the script that you use to set the TextLabel’s text?

Example of a StringValue have colored text:
A StringValue has the value “This text is red”
The same StringValue has an attribute, Color.
The Color attribute is a color type attribute, and its value is 255, 0, 0
When a TextLabel’s text is set to the StringValue’s value, the TextLabel’s TextColor is also set to the Color attribute of the StringValue.
If you need a code sample, just let me know.

I kind of do, this is hard to follow

thank you for replying

If you are setting a TextLabel’s text to the value of the StringValue, you can just change the TextColor3 property of the TextLabel. StringValues are only to hold the string itself, if you want to have more properties use Attributes or interpret the color depending on how you display it to the player.

No problem!
Ok, so this would be the code (hopefully, I haven’t tested it. Let me know if it errors)

local function setTextLabelToStringValue(textLabel, stringValue)
   textLabel.Text = stringValue.Value
   if stringValue:GetAttribute("Color") then
      textLabel.TextColor3 = stringValue:GetAttribute("Color")
   end
end
-- You can name the function whatever you want, by the way

Then, to do this you would just add a Color type attribute named “Color” to a StringValue.
This function can be run with any TextLabel and StringValue, just run the function as setTextLabelToStringValue(<insert text label here>, <insert string value here>)

Thank you, i will let you know if it works as soon as I try it, then i will mark it as a solution

tested it, and it works, just a few modifications

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