Help with a part in a text color

So, i’m having trouble with this script. This is the error I get

Players.vvKyee.PlayerGui.StartLoad.PlaceHolder.TextLabel.LocalScript:6: attempt to concatenate boolean with string

here is the script.

-- WORKING ON THE API --

local a = "Server Booster" -- A = TEXT

local b = a.TextColor3 == Color3.new(0.980392, 0.341176, 1) -- A TEXTCOLOR

local player = game.Players.LocalPlayer -- PLAYERS

local t = script.Parent -- THE TEXT

t.Text = "You do not have role, "..b.." !"

From what I see, it looks like your issue may be coming from that last line:

t.Text = "You do not have role, "..b.." !"

try changing that line to be:

t.Text = "You do not have role, ".. tostring(b) .." !"

The reason is, you are trying to concatenate, or merge, the string with a boolean value. You need to convert that boolean to a string before merging it with the other string or else it will throw an error. Hope that helps.

2 Likes

says, “, False” uh ------------

1 Like

This line will return a bool value, it is checking if the text color is equal to Color3.new(0.980392, 0.341176, 1). Is that what you want?

no, i want a certain part of the text to be a color.

Wait so what are you trying to accomplish with this line?

t.Text = "You do not have role, "..b.." !"

So, …b… would be stated a color in local b ==

You’d have to use RichText to set a certain part of the text as a color. Although you have to give it either a hexadecimal string or an rgb color

Set the property of the label that’s stored in t to have RichText to true and try this code out

-- WORKING ON THE API --

local a = "<font color='rgb(255,0,0)'>Server Booster</font>" -- A = TEXT

local player = game.Players.LocalPlayer -- PLAYERS

local t = script.Parent -- THE TEXT

t.Text = "You do not have role, "..a.." !"

This just to give an example, will set the text Server Boosters to red, you can tweak it around to get the color you want, the effect may not show if your text is already red

1 Like

Your statement:

Is wrong because you already said “b” = a colour,
And what the script is reads is:
Hmm You do not have a role , ? Huh, I’ve been asked to say something but its a colour? So… (super thinking, big brain) I will put, true because B DOES equal [your colour] ,
Now what I mean by that is a variable should not (in most cases) contain an answer,

Unhelpful script, sorry for the inconvenience

try doing this

Local b = a.TextColour3

That should change it, if you want something a bit more fun, try using a TextColour3 value or Colour3 attribute (in the properties section)!

I hope this helps!

That wouldn’t help what @OP wants either, they want a certain part of the text to be a specific color, which is only possible through RichText.

Yes what they did was incorrect since they’re using a condition in a variable to “check the color” which jsut returns true or false, but even then, it doesn’t assist them with how they have to do it into to achieve what they require

1 Like

Oh, sorry I realised what he meant now, sowwy for the inconvenience, I’ll try editing my message and making it a bit better, without removing anything!

1 Like