Answered by
8 years ago Edited 8 years ago
Lerp
You can use the lerp
function on Color3 datatypes. "Lerp" is short for "Linear Interpolation", and takes in 2 arguments:
Color3
end goal: What you're trying to get to
Number
alpha: Number between 0 and 1, acting as a percentage between start and end
Usage
Since you're looking for a smooth transition, you should use a numerical for loop. Syntax looks like this:
for [var] = [start],[finish],[(optional) increment] do
[code]
end
Use your color goal as the first argument in the Lerp function, and then your [var] divided by your [finish] to indicate a gradual climb.
Code
01 | local part = workspace.Part |
02 | local color = Color 3. new( 0 , 0 , 0 ) |
06 | local c = part.BrickColor.Color:lerp(color,i/smooth); |
07 | print (BrickColor.new(c.r,c.g,c.b)); |
08 | part.BrickColor = BrickColor.new(c.r,c.g,c.b) |
Note: BrickColors and Color3s do not translate perfectly. You may notice some odd colors pop up but for the most part, the transition is normal.