Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How could I make the color change look more smoother?

Asked by 7 years ago

For example Kahoot it's background color changes really smoothly, how could I edit this script to do something like that?

while true do
    wait(.25)
    script.Parent.BackgroundColor3 = Color3.new(85, 0, 127)
    wait(.25)
    script.Parent.BackgroundColor3 = Color3.new(0, 85, 255)
    wait(.25)
    script.Parent.BackgroundColor3 = Color3.new(0, 170, 0)
    wait(.25)
    script.Parent.BackgroundColor3 = Color3.new(255, 255, 0)
    wait(.25)
    script.Parent.BackgroundColor3 = Color3.new(255, 85, 0)
    wait(.25)
    script.Parent.BackgroundColor3 = Color3.new(255, 0, 0)
end
0
How about using tweenService? chandrakantswarnkar 2 — 7y
0
TweenService can only be used on BaseParts and judging my the BackGroundColor3 property, this is on a GUI class. SkeletalReality 590 — 7y

1 answer

Log in to vote
2
Answered by
caoshen 96
7 years ago
Edited 7 years ago

You could use the Color3 lerp method. It takes two arguments: a Color3 value (goal) and a number value (alpha).

Incorporate this into a for loop, and you have a smooth transition between two different colours.

function lerpToColor3(obj, c3)
    for i = 0, 1, 0.05 do
        obj.BackgroundColor3 = obj.BackgroundColor3:lerp(c3, i)
        wait()
    end
end

Where obj is the Gui instance being modified, and c3 is the goal you're trying to reach, e.g.

lerpToColor3(script.Parent, BrickColor.new("Bright red").Color)

I'm not entirely sure whether this is a great implementation or not, but I hope it works! Here's the wiki article for reference.

0
Thanks, I will for sure try this out and maybe make a list of different BrickColor names! YouSNICKER 131 — 7y
Ad

Answer this question