How to get BrickColor from Color3

I have these variables:

Primary_Color = BrickColor.new('Really black'),
Secondary_Color = BrickColor.new('Institutional white')

And I am trying to change them like this (using Primary as the example)

Primary_Color = BrickColor.new(v.ImageColor3)
primaryButton.ImageColor3 = Primary_Color.Color -- ERROR HERE

Please, no responses saying to just change the variables to Color3. I’m not doing that and I want to stick with BrickColor.

This is the error code btw:

[bad argument #3 to ‘ImageColor3’ (Color3 expected, got BrickColor)]=

I am curious as to why you don’t want to use Color3. Are you facing issues understanding how to use it or is it some other reason? Usually it makes life easier rather than having to do this.

6 Likes

Are you sure that is the right line and that this is the exact script?
I just ran this:

local primaryButton = game.StarterGui.ScreenGui.ImageLabel 
local Primary_Color = BrickColor.new("Really red") 
primaryButton.ImageColor3 = Primary_Color.Color

in the command bar with - obviously - an ImageLabel in a ScreenGui and it worked:
https://gyazo.com/7b7a7a08b5689523b7e8256847df3d00

To get the BrickColor of a Color3 you can do

BrickColor.new(color3)

If you want the Color3 of a BrickColor try

BrickColor.new(“Black”).color
17 Likes

Judging by @Ankur_007’s code, I think that’s the easiest way to get BrickColor from Color3.

I also modified it slightly to add a secondary color variable - if you want to use it in an ImageButton, do so and add the following code in a LocalScript under an ImageButton:

local primaryButton = script.Parent
local Primary_Color = BrickColor.new("Really red")
local Secondary_Color = BrickColor.new("Institutional white")

primaryButton.MouseButton1Click:Connect(function()
	primaryButton.ImageColor3 = Primary_Color.Color
	wait(3)
	primaryButton.ImageColor3 = Secondary_Color.Color
end)

Edit the code however you like. If you’re instead planning to use an ImageLabel, delete lines 5 and 9 (the function).

Let me know if any of this helps :slightly_smiling_face:

5 Likes