Changing particle colors via script

I have a part that changes from white to black repeatedly, and I want the same to happen with the particles on that part. But I can’t seem to change the script so it works with particles.

Here is the part:

I want the particles to do the same thing that the part is doing.

Here is the script:

local TweenService = game:GetService("TweenService")
local part = script.Parent
local TweeningInformation = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.Out,
	753475938457843579348573,
	true,
	0
)

local PartProperties = {
	Color = Color3.fromRGB(0,0,0)
}

local Tween = TweenService:Create(part,TweeningInformation,PartProperties)
Tween:Play()

Is there anything I can change so the particles also become tweened?

Particle colors use a so called ColorSequence since particles can have gradients.

Also as a little tip you can set the repeat amount to “-1” which will make the tween repeat infinitely.

1 Like

Like @Niestrat99 said, particles use a ColorSequence property for their color, which cannot be tweened.
If you want, you can create your own system for tweening the property using loops or .PreRender with mathematical functions.

There’s another script I tried to use, which does work with particles, but it doesn’t become white, then change to black, and repeat. Instead, it goes from black to white, then starts over at black again.

local t = 2;

while true do
	task.wait()
	local hue = tick() % t / t
	local color = Color3.fromHSV(0,0,hue) 
	script.Parent.Color = color
end

Notice how the particles go from black to white, then restart to black, instead of going from black to white, then white to black, then restarting.

Is there anyway to fix this?