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

Create a part which cycles through rainbow colors?

Asked by 2 years ago

I saw a game where parts cycle through the colors of a rainbow, and I'd like to learn how this is done. This is as far as I've gotten, however the part just seems to flash between red and pink.

local H = 0

while true do
    Part.Color = Color3.fromHSV(H, 1, 1)
    H += task.wait()
end

1 answer

Log in to vote
1
Answered by
Befogs 113
2 years ago

When using Color3.fromHSV your parameters should be in the range [0, 1]. To fix this just get the decimal portion of H, which can be done by using the modulo operator (%). a % b will give you the remainder of a when divided by b. This means H % 1 is just the decimal portion of H, which is in the range [0, 1).

Part.Color = Color3.fromHSV(H % 1, 1, 1)
Ad

Answer this question