I'm trying to make a gui which background changes color, which is randomly generated, and the gui will interpolate between the colors.
But, this is what happens
Inside the color changing script
A = game.Workspace.WallReception:GetChildren()
while true do
newColor = Color3.new(math.random(0,255)/255,math.random(0,255)/255,math.random(0,255)/255)
game.Workspace.NewColor.Value = newColor
wait(10)
end
Inside the GUI/Color Interpolation
local function linearInterpolation(v0, v1, alpha)
return v0*(1-alpha) + v1*alpha
end
local gui = script.Parent.FrameA
local color0 = script.Parent.FrameA.BackgroundColor3
local color1 = game.Workspace.NewColor.Value
local duration = 1
local elapsed = 0
local alpha = 0
while (alpha < 1) do
color0 = script.Parent.FrameA.BackgroundColor3
color1 = game.Workspace.NewColor.Value
elapsed = elapsed + wait()
alpha = math.min(elapsed/duration, 1)
local newColor = Color3.new(
linearInterpolation(color0.r, color1.r, alpha),
linearInterpolation(color0.g, color1.g, alpha),
linearInterpolation(color0.b, color1.b, alpha)
)
gui.BackgroundColor3 = newColor
end
eLunate's update:
local nwColor = game.Workspace.NewColor
local gui = script.Parent.FrameA
local color0 = script.Parent.FrameA.BackgroundColor3
local color1 = game.Workspace.NewColor.Value
nwColor.Changed:connect(function()
script.Parent.FrameA.BackgroundColor3.lerp(color0,color1,1)
end)

3 comments
Like CFrame:lerp() but for colors? Cool
Huh, didn't work. I'm probably doing something wrong, but please check my update.
Your current code will literally just set it to color1