Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Create a part which cycles through rainbow colors?

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

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.