--[[
	Sets rate to 0, then waits for particle lifetime before destroying, as destroying an emitter immediately
	removes all it's particles as well.
]]

return function(particleEmitter, delay)
	if not particleEmitter or not particleEmitter:IsA("ParticleEmitter") then
		return
	end
	coroutine.wrap(
		function()
			if delay and tonumber(delay) then
				wait(delay)
			end
			particleEmitter.Rate = 0

			wait(particleEmitter.Lifetime.Max)
			particleEmitter:Destroy()
		end
	)()
end
