TweenService giving me random colors after about 10 seconds

Hello, I have a tween that changes the color of parts to purple. The script works fine for about 10 seconds, but then the colors start becoming random. I only have this script in an empty baseplate, and no free models.

This gif shows what it looks like.

Here is the entire script I’m using.

local tweenService = game:GetService("TweenService")

local tweeninfo = TweenInfo.new(
	.75,
	Enum.EasingStyle.Back,
	Enum.EasingDirection.In,
	1,
	true
)

local num = 0

while wait() do
	for i = 1, #script.Parent:GetChildren() do
		wait()
		if not (num == (#script.Parent:GetChildren() + 1)) then
			num +=1
			if script.Parent:FindFirstChild(num) then
				local tween = tweenService:Create(script.Parent:FindFirstChild(num), tweeninfo, {Color = Color3.fromRGB(167, 94, 155)})
				tween:Play()
				wait()
			end
		else
			num = 0
		end
	end
end

Any help would be appreciated, thanks!

I figured out what I was doing wrong, the Tweens were overlapping each other causing the random colors. Thanks!

I think this might be because the part is getting tweened while it’s already tweening

I think this could work but I’m not 100% sure

local num = 0
local tweentable = {}

while wait() do
	for i = 1, #script.Parent:GetChildren() do
		wait()
		if not (num == (#script.Parent:GetChildren() + 1)) then
			num +=1
			if script.Parent:FindFirstChild(num) then
				if not tweentable(num) then
					tweentable(num) = true
					local tween = tweenService:Create(script.Parent:FindFirstChild(num), tweeninfo, {Color = Color3.fromRGB(167, 94, 155)})
					tween:Play()
					tween.Completed:Connect(function()
						tweentable(num) = false
					end)
					wait()
				end
			end
		else
			num = 0
		end
	end
end
2 Likes

It didn’t, but thanks for replying!

It may be because of the easing style, as the complementary color for purple is green. Try changing the style to linear.

Edit: I just read the last part of your post and I’m mostly right.