Setting Color3.new() gives the part the wrong color when values < 0.1

Essentially, setting the color of a part with Color3.new() sets the RGB values slightly incorrectly, which can lead to a big difference if set repeatedly. I’ll give an example below:

Steps to reproduce:

  • Imagine we have two parts, Part and Part2.
  • “Part” has a Color of (25, 255, 0).
  • If we print that value we get (0.0980392, 1, 0) in the normal 0-1 range.
  • Now, we set “Part2”'s Color to Color3.new(0.0980392, 1, 0) [or Color3.new(0.098, 1, 0) to save characters.]
  • If we now print Part2’s Color, we get (0.0941176, 1, 0), or the equivalent of (24, 255, 0).
  • As you can see, the Color changed from (25, 255, 0) to (24,255,0).

This is quite a big issue in my game, Obby Creator , where parts’ colors are saved and loaded back in repeatedly. Eventually, the color becomes (0, 255, 0) which is just completely wrong.

image

NOTE: This only occurs with RGB values < 26, as seen in the image below where I use the equivalent of (26, 255, 0). I assume it’s something to do with the value being < 0.1 in the 0-1 range, but I may be wrong.

image

6 Likes

Another way to do deal with colors and to avoid this bug is doing
Color3.fromRGB() – if RGB is wanted
or
Color3.fromHSV() – if HSV is wanted

4 Likes

This is most likely due to floating point errors.

3 Likes

It seems this has to do with repeated distortion of the colour. It’s likely a deeper issue within how Part colours are handled.

Machines aren’t always perfect, floating-point errors are small “artifacts” that keeps appearing time to time in certain work with computers, creating imprecise representation of something. This affects incredibly large and small numbers.

2 Likes

Thanks for the report! We’ve filed a ticket to our internal database and we’ll follow up when we have an update for you.

Please note that filling a bug report does not guarantee that it will be fixed once triaged.

4 Likes

Hi there, thanks for filing this bug report. This is closed as not a bug, As per our engineers: Not a bug. This is how floating point numbers work.

2 Likes

This topic was automatically closed after 6 days. New replies are no longer allowed.