local function z(z)local h=(.2126*z.r+.7152*z.g)+.0722*z.b return h<.4 end local function h(z,h,U)local k=tick()while tick()-k<U do wait(1/MAX_STEPS)local V=z:Lerp(h,(tick()-k)/U)COLOR=Color3.new(V.x,V.y,V.z)if V.x<1 and(V.y<1 and(V.z<1 and(V.x>0 and(V.y>0 and V.z>0))))then script.Parent.Value=Color3.new(V.x,V.y,V.z)end end end while true do if tick()-t>=30 then math.randomseed(tick()/2)end t=tick()local U repeat U=BrickColor.Random()until not z(U.Color)print(U)h(Vector3.new(COLOR.r,COLOR.g,COLOR.b),Vector3.new(U.Color.r,U.Color.g,U.Color.b),2)end
-- For luminance calculation formula look at: http://en.wikipedia.org/wiki/Grayscale
local function IsDark(color)
	local cieLuminance = 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b
	return cieLuminance < 0.4
end

local function LerpColor(startColor, endColor, duration)
	local startTime = tick()
	while tick() - startTime < duration do
		wait(1 / MAX_STEPS)
		local lerpedVec = startColor:Lerp(endColor, (tick() - startTime) / duration)
		COLOR = Color3.new(lerpedVec.x, lerpedVec.y, lerpedVec.z)
		if
			lerpedVec.x < 1
			and lerpedVec.y < 1
			and lerpedVec.z < 1
			and lerpedVec.x > 0
			and lerpedVec.y > 0
			and lerpedVec.z > 0
		then
			script.Parent.Value = Color3.new(lerpedVec.x, lerpedVec.y, lerpedVec.z)
		end
	end
end

while true do
	if tick() - t >= 30 then
		math.randomseed(tick() / 2)
	end
	t = tick()
	local newcolor
	repeat
		newcolor = BrickColor.Random()
	until not IsDark(newcolor.Color)
	print(newcolor)
	LerpColor(
		Vector3.new(COLOR.r, COLOR.g, COLOR.b),
		Vector3.new(newcolor.Color.r, newcolor.Color.g, newcolor.Color.b),
		2
	)
end
