Rainbow Cycling?

I have create a script but I am unsure if it is practical as it pauses on red for a tiny but because it uses sine

local Frequency = 1
local AngularFrequency = 2 * math.pi * Frequency / 255
local Phase = math.rad(0)

game:GetService("RunService").RenderStepped:Connect(function()
    Part.Color = Color3.fromHSV(math.abs(math.sin(AngularFrequency * tick() + Phase)), 1, 1)
end)

is there a better way?

1 Like

I am unsure if you’re trying to get specific values, but you can just use this:

BrickColor.random()

1 Like

No smooth transitions between all colours

1 Like

You can just tween the color using TweenService.

1 Like

Tween through all the colours of RGB. I am looking for something like my script that does not pause long on red

1 Like

image

Just choose 5-10 checkpoints in this spectrum, and tween per checkpoint.

1 Like

How is that more efficient then what I am doing?

1 Like

You could just use TweenService on a NumberValue to do it.

local tweenService = game:GetService('TweenService')
local numberValue = Instance.new('NumberValue')
local part = workspace.Part

local tween = tweenService:Create(numberValue, TweenInfo.new(10, Enum.EasingStyle.Linear), {Value = 1})

numberValue.Changed:Connect(function()
    part.Color = Color3.fromHSV(numberValue.Value, 1, 1)
end)
while true do
    tween:Play()
    tween.Completed:Wait()
    numberValue.Value = 0
end
1 Like

Hi!

Make a script and insert this code. Make sure to insert the script in the part you’d like to tween. :smiley:

local tweenService = game:GetService("TweenService");

local tweenInfo = TweenInfo.new(
	1,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.InOut
)

function tweenParentColor(color) 
	local PanelSlideTween = tweenService:Create(script.Parent, tweenInfo, {
		Color = color
	})
	PanelSlideTween:Play()
	wait(1)
	return
end

while true do
	-- red
	tweenParentColor(Color3.new(1, 0, 0));
	
	-- orange
	tweenParentColor(Color3.new(1, 0.647, 0));
	
	-- yellow
	tweenParentColor(Color3.new(1, 1, 0));
	
	-- green
	tweenParentColor(Color3.new(0, 0.502, 0));
	
	-- blue
	tweenParentColor(Color3.new(0, 0.333333, 1));
	
	-- blue
	tweenParentColor(Color3.new(0, 0, 1));
	
	-- Indigo
	tweenParentColor(Color3.new(0.294, 0, 0.510));
	
	-- Indigo
	tweenParentColor(Color3.new(0.9333333, 0.510, 0.9333333));
end
1 Like

This should work?

for i = 1, 360 do
    local col = Color3.fromHSV(i/360, 1, 1)
end
2 Likes

Then consider usage of TweenService