Color not smoothly changing?

I have a Frame that I want to change the color smoothly, I know I can accomplish this with a Tween but I wanted to see this way first.
Can someone explain why this doesn’t work?

Theme1.MouseButton1Click:Connect(function()
	local t = 0.2;

	while true do
		task.wait()
		local hue = tick() % t / t
		local color = Color3.fromHSV(0.0276389, 0.780392, 1) 
		script.Parent.Parent.Parent.BackgroundColor3 = color
	end
end)

image
ur not using hue variable

I had changed it to RGB after I posted this and it still didn’t work.

Theme1.MouseButton1Click:Connect(function()
	local t = 0.2;

	while true do
		task.wait()
		local hue = tick() % t / t
		local color = Color3.fromRGB(199, 140, 87) 
		script.Parent.Parent.Parent.BackgroundColor3 = color
	end
end)


Since tween service is not good for performance he needs other method.

1 Like

Here’s a little example i’ve made, you can try it.

Theme1.MouseButton1Click:Connect(function()
	while true do
		for i = 0,1,0.001*1 do
			script.Parent.Parent.Parent.BackgroundColor3 = Color3.fromHSV(i,1,1)
			task.wait()
		end
	end
end)

This is rainbow color, but smooth.

As TweenService does work perfectly fine without causing any issues it is okay, I was just trying to see how come the other script wasn’t working

I know, but tween service isnt a good choice in loops that run continuously.
those who have low end device will suffer from lag, which can cause low player count.

@eggspIicit Try this

Theme1.MouseButton1Click:Connect(function()
	local t = 0.2;

	while true do
		for hue = 0,tick() % t / t,0.001*1 do
			task.wait()
			local color = Color3.fromHSV(hue, hue, hue) 
			script.Parent.Parent.Parent.BackgroundColor3 = color
		end
	end
end)

I don’t know what color are you trying to achieve, so I am making it a random color.
To change the speed of color changing then multiply the wait amount with 0.001
image