2D Particle Emitter

Sorry these demonstrations were made specifically for my game so I can’t make them public.

Thank you for this! I was about to just make a system for this on my own but I decided to look for a premade module and this is exactly what I was looking for!

wait what is the difference between this and making a viewport frame for effects?

Viewports don’t render particles

oh β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž

.fromParticle does not seem to be working for me. I tried it with both normal Roblox ParticleEmitters and custom ParticleEmitters, but neither worked.

Here is the code I’m using:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ParticleEmitter = require(
	ReplicatedStorage.Modules.ParticleEmitter
)

local button = script.Parent

for _, child in ReplicatedStorage.Assets.VFX.Close.Attachment:GetChildren() do
	if child:IsA("ParticleEmitter") then
		local emitter = ParticleEmitter.fromParticle(child)

		emitter.Parent = button
		emitter:BindToRenderStepped()
	end
end

The emitter is created successfully, but no particles/ImageLabels appear inside the UI.

Am I using .fromParticle incorrectly, or is there something I’m missing?

You need to take this into account when using .fromParticle


The module doesn’t convert Speed and Size automatically so you need to do it manually. A common way you can do this is by multiplying the Speed and Size with some sort of scale factor, I’ve attached an example below where you can try it out for yourself.

local function multNumberSequence(sequence: NumberSequence, scale: number)
	const keypoints = {}
	for i = 1, #sequence.Keypoints do
		const keypoint = sequence.Keypoints[i]
		const envelope = keypoint.Envelope * scale
		const value = keypoint.Value * scale
		const t = keypoint.Time
		
		table.insert(keypoints, NumberSequenceKeypoint.new(t, value, envelope))	
	end
	return NumberSequence.new(keypoints)
end

local function multNumberRange(range: NumberRange, scale: number)
	if typeof(range) == "number" then
		return range * scale
	end
	return NumberRange.new(range.Min * scale, range.Max * scale)
end

local emitter = nil -- emitter here
local scale = 32 -- 32 pixels

emitter.Speed = multNumberRange(emitter.Speed, scale)
emitter.Size = multNumberSequence(emitter.Size, scale)