Arithmetic on BasePart.Color

I’m trying to add a bit of color variance to some trees,

I figured this would be as easy as

Tree.Color=Tree.Color+Color3.new(math.random(-20,20)/200,math.random(-20,20)/200,math.random(-20,20)/200)

but no, that’s forbidden
image
because apparently both Part.BrickColor.Color and Part.Color return UserData values, and not Color3?

how would i go about slightly randomizing the color of the trees, just by 3 or 4 RGB increments apiece?

Maybe you could do something like this;

Tree.Color = Tree.Color+Color3.fromRGB(math.random(0,255),math.random(0,255),math.random(0,255))

Color3 doesn’t work with addition like that.

Instead you have to manually add the components.

local function addColors(c1,c2)
    return Color3.new(c1.R+c2.R,c1.G+c2.G,c1.B+c2.B)
end

A Color3 is a userdata.

print(type(Color3.new()))
--> userdata
7 Likes

Yikes, darn…

Ok, off to #platform-feedback:engine-features!

thanks for the script tho, it worked a treat!