Change particle colors smoothly via script

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 any way to fix this?

Couldn’t you just use TweenService?

For example if you want the particles to become white - black you can do:

-- services
local tweenService: TweenService = game:GetService("TweenService") :: TweenService

local particleEmitter: ParticleEmitter = script.Parent :: ParticleEmitter

-- functions
particleEmitter.Color = ColorSequence.new(Color3.fromRGB(0, 0, 0))

tweenService:Create(particleEmitter, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true, 0), { Color = ColorSequence.new(Color3.fromRGB(255, 255, 255)) }):Play()

no‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎

Don’t wanna be that guy but I think you should only post something if it’s necessary or if it contributes to the thread.

For someone who doesn’t wanna be that guy, you sound an awful lot like “that one guy”. which makes me think you are THAT one guy.

1 Like

Listen I just don’t want to bump this thread, and that’s all I’m saying, if you want to tell me something else, just keep it to dm’s. And if you do, just explain why the reply of ‘no’ was necessary lol

mong

while task.wait() do
   local brightness = 0.5 * (math.sin(tick()) + 1)
   local grayscaleColor = Color3.new(brightness, brightness, brightness) 
   workspace.Baseplate.Color = grayscaleColor
end

I think you should replace your current code with a Tween instead. The code which you currently have is using a loop which is rather inefficient. But that’s really up to how you’re using the function.

lmao

local f = 2

while task.wait() do
	local brightness = 0.5 * (math.sin(tick() * f) + 1) 
	local grayscaleColor = Color3.new(brightness, brightness, brightness)
	workspace.Baseplate.Color = grayscaleColor
end

f was there the whole time you just gotta look for it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.