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

Making a colour sequence that fades through colours of the rainbow?

Asked by 6 years ago

I need to know how to make a script that can (for example) change the colour of a brick so that it will continuously cycle through the colours of the rainbow.

I'm not on about a script like this:

while true do
script.Parent.BrickColor = BrickColor.new("Really red")
wait(0.1)
script.Parent.BrickColor = BrickColor.new("New yeller")
-- etc...

I need a more in-depth script that possibly uses the Color3 property to smoothly cycle through the different hues on the spectrum of light. I've seen it done before somewhere so I know that its' possible, I just can't think of the math or wrap my head around how I would do it.

Any help would be appreciated.

0
try `:Lerp()` creeperhunter76 554 — 6y
0
Why? He wants a ColorSequence, probably for a trail or whatever else needs ColorSequences hiimgoodpack 2009 — 6y
0
A ColorSequence would be beneficial but I don't think you can have ColorSequences when using Parts? (Unless I'm mistaken) plagueus 44 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I made a rainbow before. To make a color sequence, you need ColorSequenceKeypoint.new. The first parameter is the time, the second is the color3. Or, make an array of all your colors to use them in a trail or what you are doing. Here is what I did

function GetRainbow()
    local red = ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 4))
    local orange = ColorSequenceKeypoint.new(.221, Color3.fromRGB(255, 214, 47))
    local yellow = ColorSequenceKeypoint.new(.401, Color3.fromRGB(251, 255, 6))
    local green = ColorSequenceKeypoint.new(.566, Color3.fromRGB(28, 255, 26))
    local blue = ColorSequenceKeypoint.new(.699, Color3.fromRGB(44, 93, 255))
    local purple = ColorSequenceKeypoint.new(.897, Color3.fromRGB(255, 26, 252))
    local finish = ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 0, 213))
    local rainbow = ColorSequence.new({red, orange, yellow, green, blue, purple, finish})

    return rainbow
end

Hope this helps!

0
This seems like a strong step in the right direction, but how would I actually apply this to something? Would I just use a while loop and continuously change the Color3 property to "rainbow"? plagueus 44 — 6y
0
No, this makes a color sequence you can apply to a trail. hiimgoodpack 2009 — 6y
0
Is there any way I can apply something similar to this to a part? plagueus 44 — 6y
0
But parts cant use colorsequences............. don't you want a ColorSequence? hiimgoodpack 2009 — 6y
Ad

Answer this question