How to add a proper color to a part via script?

I’m making something in which I need to change the color of the model. However, the color does not get set correctly.

It should be brown, but the model turns blue https://gyazo.com/0bde1bba60006a3c47dd56403ce0a41c

The actual model color is 96, 161, 203, which is the RGB of the blue color.


		if frames % 30 == 0 then
			print(objectDefaults[objName].Main['MainColor'])
			for i, v in pairs(objClone:GetDescendants()) do
				if v.Name == 'Main' and mainCustomizerSelected and not v:IsA('Weld') and not v:IsA('Texture') then
					
					if currentColor == nil then
						currentColor = objectDefaults[objName].Main['MainColor']
					end
					print('Haha')
					print(currentColor)
					--v.Color = currentColor
					v.Color = currentColor
					if currentMaterial == nil then
						currentMaterial = objectDefaults[objName].Main['MainMaterial']
					end
					v.Material = currentMaterial
					
				elseif v.Name == 'Extra' and not mainCustomizerSelected and not v:IsA('Weld') and not v:IsA('Texture') then
					
					if currentColor == nil then
						currentColor = objectDefaults[objName].Extra['ExtraColor']
					end
					print('Che')
					print(currentColor)
					v.Color = currentColor
					
					if currentMaterial == nil then
						currentMaterial = objectDefaults[objName].Extra['ExtraMaterial']
					end
					v.Material = currentMaterial
					
				end
			end
		end

As you can see here, it will print the color and set the color. But it prints “Haha” and then “160, 95, 53” so it obviously isn’t setting the color correctly. Can you please help me out?

you have to divide each number by 255

I thought Color3.new does that automatically?

nope, surprisingly not, I had this problem too a while back when using color3

use Color3.fromRGB then if you want RGB values

Ok this fixed it, thank you. I tried dividing by 255 earlier and I got the same issues.

1 Like