~~ KingLoneCat
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
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.
local part = workspace.Part --This is your part local color = Color3.new(0,0,0) --This is the desired color; black local smooth = 20 --This is how smooth the transition will be for i = 1,smooth do local c = part.BrickColor.Color:lerp(color,i/smooth); --Aquire the color print(BrickColor.new(c.r,c.g,c.b)); part.BrickColor = BrickColor.new(c.r,c.g,c.b) --Convert to BrickColor wait(.05) end
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.
You could try this, a Color3
lerp
function. For example,
local start = Color3.new(1,1,1)-- White local End = Color3.new(0,0,0)--Black for i = 0,1,0.03 do wait() local color = start:lerp(End,i) end