Particle Burst in script not working

-- Default parameter stuff
	if burstSize == nil then
		burstSize = 100
	end
	
	
	
	-- Create effects block
	local pBlock = effects.CreateEffectBlock(location)
	
	-- Create particle emitter and start customizing
	local particle = Instance.new("ParticleEmitter")
	particle.Rate = 0
	particle.Shape = Enum.ParticleEmitterShape.Sphere
	particle.Color = color
	particle.Transparency = transparency
	particle.Size = size
	particle.Lifetime = NumberRange.new(length)
	particle.Speed = speed
	particle.Texture = texture
	particle.Parent = pBlock
	particle:Emit(burstSize)
	task.spawn(function()
		task.wait(length)
		--pBlock:Destroy()
	end)

All of this is in a function. There’s a lot of stuff here, and some of it is cut out, but the key parts are

  • This is in a server script
  • Everything seems to work except the Emit function

I commented out the :Destroy() to test it, and when I run :Emit() on it in the command bar, it emits. Why isn’t it working in the script, though?

Why create the ParticleEmitter each time?
Just create a Part with a ParticleEmitter already set up in it and store it in ReplicatedStorage or whereever.
Clone it when needed.

It may just be that it’s taking longer to set all this up than it has to be able to Emit.

1 Like

I hqd the same issue, instead of implementing it in the script, change the particle emitter through the properties tab, I manually changed the particles instead.

My function needs to be able to change the parameters of it though, so the only real “set up” for a lot of things would be the fact that it already exists. Would that be enough, do you think?

Give it a try to see if it helps.

Well, on the one hand, I realized that this method just works much better for what I’m doing, so thanks for reminding me of it.
On the other hand, it didn’t actually fix the problem.
I looked up some other things, and the few I saw said to just put a quick wait() in front of it; but, as is expected with wait(), it’s pretty inconsistent. Sometimes it’s there, sometimes it isn’t.

I’m unsure how long you’re waiting, but you can also just use Debris, which just allows you to time the deletion of an instance. Debris | Documentation - Roblox Creator Hub

Also, you’re particle rate is hard coded on 0, and I don’t use particles that much, but doesn’t that mean it wont produce a particle?

It means it won’t produce particles naturally. Emit forces a burst of particles. That way I can get an explosion of particles all at once without some stragglers.

A bit of a side track, but honestly it is a good idea, and probably more efficient. I’ll do that.