Issue with tweening Part.Color

I’m working on a color block game where all the blocks disappear and 1 color gets chosen to remain, the issue I’m having is that when I try tweening a block to a certain color for e.g. Color3.fromRGB(20, 20, 20) some part colors change and the ones that don’t change have color values such as 20,19,20 or 19,19,20 etc, when it should be 20, 20, 20. I have not yet found any solutions or leads

Getting the color goal for the tween, for example Color3.fromRGB(20,20,20)
image

Tweening the color of the block to the given color (Color3.fromRGB(20, 20, 20)
image

The tween function (in another modulescript)

What it tweens to. It should be 20, 20, 20 as shown above but it’s 19, 20, 20

Would appreciate any help.

2 Likes

I wouldn’t stress about it as long as the values only change by 1/-1, since the color doesn’t change that much.

Ah yeah but I’m trying to compare values seen here

So basically if the part color is equal to the selected color then that part wouldn’t disappear

Have you tried changing Color3.fromRGB to Color3.fromHSV? Perhaps that could fix the issue? Documentation about Color3.

Not really trying to use fromHSV since I’m working with RGB for both UI Components and part colors, thanks though.

Possibly try checking something else instead of the Color?

You could try setting the color of the block to the goal color when the tween finishes

Ultimately, I believe this is an issue with how computers handle math. It’s an interesting topic, I recommend giving this video a watch if you’re interested.

Getting back on topic though, even if you used Color3.fromRGB, Color3 values are converted to a decimal value from 0 to 1. 0 being black, 1 being white. The issue is that roblox displays Color3 values in the explorer as the 0-255 RGB format. And since you need to approximate these values, there can be rounding inconsistencies. Ultimately, shouldn’t be a major problem, even if you’re comparing two Color3 values. It’s just a minor display difference.

had no other choice but to resort to this and it works perfectly fine now, thank you

it indeed is an interesting topic and quite challenging to deal with for me at least, I changed the color3 exactly to what it should be when the tween is completed, it works fine now. thank you

1 Like