Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to get BrickColor to Color3?

newchatline.TextColor3 = BrickColor.new(player.TeamColor).Color3 -- This is line 170

Don't worry about newchatline, I just want to know how can I get a person team color (BrickColor) to work with TextColor (Color3)? ServerScriptService.Chat:170: bad argument #1 to 'new' (Color3 expected, got userdata)

2 answers

✓ Accepted answer

To convert a BrickColor datatype into a Color3 datatype, you have to know the syntax for the Color3 scale.

Color3.new( RED / 255, GREEN / 255, BLUE / 255 )

So, what do you see here? The Color3 scale takes numbers out of 255 and it's in standard RGBformat.


Now, did you know you can index the specific color inputs(on the RGB format) of BrickColors? All you have to do is input these into a Color3 scale(:


local BrickColor = BrickColor.new('Bright red') --Your wanted BrickColor

function transformToColor3(col) --Function to convert, just cuz c;
	local r = col.r --Red value
	local g = col.g --Green value
	local b = col.b --Blue value
	return Color3.new(r,g,b); --Color3 datatype, made of the RGB inputs
end

transformToColor3(BrickColor) --> And a Color3 value was born(:

3 comments

0

thanks :)

0

No problem! c:

1

An easier method is to simply use the Color property that all BrickColors have -- it automatically converts the BrickColor to Color3. BrickColor.new("Really red").Color

Theres another way thats less complicated.

Clr3Return = function(color)
	return color.Color
end

.TextColor3 = Clr3Return( BrickColor.new("Lime green") )
print(
	Clr3Return( BrickColor.new("Lime green") )
)

1 comment

1

There's no point to use a function for this, since .Color is just as clear and shorter than a function call.

This discussion is preserved as it was. New answers, comments, and votes are closed.