Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to get BrickColor to Color3? [closed]

Asked by 9 years ago
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)

Locked by NinjoOnline, Redbullusa, MessorAdmin, and Perci1

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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(:
0
thanks :) NinjoOnline 1146 — 9y
0
No problem! c: Goulstem 8144 — 9y
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 Perci1 4988 — 9y
Ad
Log in to vote
2
Answered by 9 years ago

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
There's no point to use a function for this, since `.Color` is just as clear and shorter than a function call. BlueTaslem 18071 — 9y