Cannot make infinitely smoothly changing color parts

I wanted to make parts infinitely smoothly change colors,but when i try it changes colors so fast that my eyes start hurting,how can i fix it so it would be slow?


local TweenService = game:GetService("TweenService")
local function yes()
	for i,part in pairs(workspace.NeonRoom:GetChildren()) do
		TweenService:Create(part,TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0),{Color = Color3.new(math.random(0,255),math.random(0,255),math.random(0,255))}):Play()
	end
end
while true do
	yes()
	wait(5)
end

To change the tween duration you need to specify it inside your TweenInfo.
You can see TweenInfo “values” under the Constructors part on this website
https://developer.roblox.com/en-us/api-reference/datatype/TweenInfo
Currently, your tween duration is at 5

I know,it for some reason ignores it and the colors are swapping so fast that my eyes hurt

After doing some test I remembered that Color3 is often the problem when dealing with Color,

Try to change Color3.new to Color3.fromRGB

1 Like

Thank you,it started working now

You are not waiting for the tween to finish playing in your for loop. You are just playing it and then playing another at the same time. You can fix it like this:

local TweenService = game:GetService("TweenService")

local colorTweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

local random = math.random
local function yes()
	for i,part in pairs(workspace.NeonRoom:GetChildren()) do
		local colorTween = TweenService:Create(part, colorTweenInfo, {Color = Color3.new(random(), random(), random())})
		colorTween:Play()
		colorTween.Completed:Wait()
	end
end

while task.wait(5) do
	yes()
end
1 Like

I don’t think that’ll be of any help in this case for @OP, that would mean each part is going to have to wait for the other to finish changing color before they can change color, which makes their NeonRoom lose purpose

The issue was because they were using Color3.new with values above 1 rather than Color3.fromRGB, so the code was working, just a wrong constructor was used

I understand that, mistakes happen

1 Like

Oops. My bad. I mis-read the script and thought they were iterating through colors, although I also noticed that and corrected it in my response. Lol.

1 Like

I do have thinked the same thing but didn’t say it, I wouln’t have done it like that but it’s look better than mine. I also think that even if it’s not what he asked, this may help him undestand a lot better how Tweening work since wait() isn’t reliable for that.

1 Like