ImageColor3 Question

DuYfdP2 - Imgur

I have this healthbar that I made black and white so I can change it from green to yellow and then to red using ImageColor3.

How would I set the ImageColor3 property so it perfectly reflects the healthbar before I made it black and white?


Some simple algorithm like this may work for you, if I understood your question correctly, this would provide you with a transitioning color from green to red based on player health.

local health = humanoid.Health / humanoid.MaxHealth
image.Color3 = * (health - 1), 1 * (health), 0)

1 Like

No, I guess I should have been more clear. I am not trying to transition the color. I want it to match the image’s RGB values perfectly before it was turned to black and white but with ImageColor3.

I’m still struggling to understand what you’re trying to do… :confused:

I have to images on my local PC. One is black and white and the other has the green. You can see the images in the GIF. How can I change the ImageColor3 value of the uploaded black and white image so the image matches the green image on my PC. Example: if I use a color picker on the original green image and the black and white with ImageColor3 on the top left pixel the RGB value would be exactly the same.

You can’t. The image is darker after you turn it to black and white, and ImageColor3 only allows you to remove color, not add it. The green in the corner goes from (147, 200, 86) to (171, 171, 171) and, with the black and white texture, you can’t get any rgb values for any of the colors higher than 171.

Basically, just use a lighter texture or settle for a slightly off version when using ImageColor3.

1 Like

Yeah, it seems so. Even if I get the top left pixel the exact same, the others wouldn’t be. I’ll have to just upload three separate images.

The problem isn’t that they don’t get adjusted evenly, they definitely should be. I’m pretty sure it’s just that the green value can’t go any higher than it is to begin with, and your black and white image has a lower green value than the original.

1 Like

My recommendation is to make it black and white then make it so the brightest color is white (not grey) (try increasing the brightness).
Image color is determined by PixelColor * ImageColor3 so you could try sampling the brightest color on the green pallete and you should get a similar result.
As for making it change colors from green to red, use Color3.fromHSV.

The hue should let you slide around the rainbow while maintaining the same “saturation” / “brightness.”