How to change the speed of a particle emmitter via a script?

Hello DevForum! Today I am attempting to make a fountain, my goal is after 5 seconds the fountain reaches the maximum speed then after another 5 seconds goes down to a deficient. Here is my script:

local maxfountainspeed = 49,50
local minfountainspeed = 0,1



script.Parent.ParticleEmitter.Speed = NumberRange(maxfountainspeed)
wait(5)
script.Parent.ParticleEmitter.Speed = NumberRange(minfountainspeed)
1 Like

For going up in speed you can do:

for i = 1, 50 do
		particleEmitter.Speed = i
		wait(0.1)
	end

And for going down in speed:

for i = 50, 1, -1 do
		particleEmitter.Speed = i
		wait(0.1)
	end

You could also make an infinite loop:

while true do
	for i = 1, 50 do
		particleEmitter.Speed = i
		wait(0.1)
	end
	for i = 50, 1, -1 do
		particleEmitter.Speed = i
		wait(0.1)
	end
end

These will all slowly increase or decrease the speed.

1 Like

This doesn’t fix OP’s problem, since the Speed property expects a NumberRange, not a number.


The issue here is that only the value 49 gets read into the maxfountainspeed variable, while the other value is ignored. You can just create a NumberRange with the values:

local maxfountainspeed = NumberRange.new(49, 50)
local minfountainspeed = NumberRange.new(0, 1)

script.Parent.ParticleEmitter.Speed = maxfountainspeed
wait(5)
script.Parent.ParticleEmitter.Speed = minfountainspeed
4 Likes