Why am I not getting the right Color3 values?

Hello everyone, so this is my code:

local origColor = Instance.new("StringValue", v) origColor.Name = "OriginalColorValue" origColor.Value = tostring(v.Color)

Where v represents the single part within the overall model.

But when I get the value of tostring(v.Color) it gives me (0.0666667, 0.0666667, 0.0666667) instead of the Color3 value (17, 17, 17) which is the accurate Color3 value for this part. Does anyone know what’s going wrong here? Why am I getting different numbers for something like this? Thank you.

1 Like

Because Color3 values are represented from 0 to 1 rather than 0 to 255, if you want them to be represented as actual RGB values, you need to multiply by 255 which is the max amount a RGB value can go, and round down the decimal value, which should give you the Value.

Example:

Red = math.floor(Color.R*255)
2 Likes

Thanks, but I did this and still nothing is working:

local originalColor = Color3.new(origColor.Value) local colorOfPart = math.floor(originalColor*255) v.Color = colorOfPart

Where origColor.Value = (0.0666667, 0.0666667, 0.0666667)

Know what I did wrong? Thanks.

Basically the question is how do I feed this 0 to 1 number so it can change the color of the part?

You cannot multiply a Color3 value, you have to multiply the values separately.

Instead of storing the Color3 as a StringValue, try using Color3Values instead

2 Likes

Is there any way that I can give the 0 to 1 value and it changes it automatically or do I have to go through the process of individually editing them? Thanks

Okay so I do this: math.floor((0.666667) *255) 3 times and make that a Color3 value? Am I correct?

I think there may be a function to do this for you, if not you might have to manually do it, if you want, you can create a function so you dont have to keep writing the same code.

And Yes, It should, as far as im aware.

He may be trying to do something with the Values. And have them represented on something. Color3Values work, but their values are represented as 0 to 1, but in testing, it should be seen from 0 to 255 within its Properties.

Okay, I fixed it, thanks for the help guys. All I did was make a new function like this:

function color3torgb(color3)
	local r = color3.R
	local g = color3.G
	local b = color3.B
	
	local newColor = Color3.new(r, g, b)
	return newColor
end
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.