Back to open source

Archived and not maintained. No updates or fixes. For new games, use Roblox's built-in ParticleEmitter2D (in Studio beta for now).

Open sourceArchivedNot maintained2022 to 2023

2DEmitter

A 2D particle emission module for Roblox UI. I built it on my own and gave it away on the DevForum as a free developer resource.

PlayerGui › 2DEmitterclick to emit
A browser port of the module's Default particle.
first released
Mar 2022
to build V1
2 days
likes on the post
45
views on the post
10.6K

Liked on the DevForum.

The original post went up in Community Resources in March 2022. Likes mean people found it useful. Nobody here endorsed it or worked on it with me.

Hazem (@haz3mn), a well-known Roblox developer, was the first of the 45 people who liked the post.

likes
45
views
10.6K
Roblox Model link clicks
1.1K
GitHub link clicks
502

2DEmitter - Create beautiful UI particles

ResourcesCommunity ResourcesMarch 2022

GitHub - Synitx/2DEmitter502
2D Emitter - Roblox1.1k
45Reply

Liked by

  • hazem@haz3mn
  • SOTR654@SOTR654
  • Fe4528@Ballistic_Scarf
  • Ahmed@Is_Script
  • 01_xXAxel2021Xx@01_xXAxel2021Xx
  • WaykorFx2@WaykorFx2
  • EKmaster@EKmaster2005
  • trippy@TrippyGhostOG

and 37 more

Recreated from the post. The DevForum lists likes in this order.

Raw screenshotThe post as it looks on the DevForum
The original 2DEmitter DevForum post with its GitHub and Roblox Model links, and the list of people who liked it open, showing hazem (@haz3mn) at the top and 45 likes.

Particles, but for UI.

Roblox's ParticleEmitter only works in the 3D world. It can't draw inside a ScreenGui, so effects like a reward pop or a button burst had to be tweened by hand every time.

What it does

You give it a point on the screen. It spawns small GUI particles there and sends them flying out, spinning, fading and shrinking, with the size, speed, colours and spread you set.

Why I built it

It filled that gap with plain GUI objects and TweenService, so any game could have UI particles from a few lines of code. I wrote the first version in 2 days, in March 2022.

How it was shared

Free and open source on GitHub, as a Roblox Model, and in a DevForum post with docs. I asked people not to resell it or claim it as theirs.

See it move.

The two clips are the original demos from the DevForum posts. The playground runs a browser port of the module's Default particle with the same rules, so you can change every property and copy the Luau.

2DEmitter V1 demoFrom the original post, March 2022.
2DEmitter V2 demoFrom the V2 plugin post, January 2023.

Playground

Click the screen to emit. The Luau underneath updates as you go and uses the module's real API.

PlayerGui › 2DEmitterclick to emit
Particles.client.luau
local Emitter2D = require(path.to.2DEmitter)

local emitter = Emitter2D.new(UDim2.fromScale(0.5, 0.5))
emitter:Set({
	Amount = 40,
	Size = 3,
	Speed = 0.9,
	LifeTime = Vector2.new(60, 170),
	Color = { Color3.fromRGB(61, 125, 255), Color3.fromRGB(108, 157, 255), Color3.fromRGB(255, 255, 255) },
	Corner = UDim.new(0, 2),
})
emitter:ToggleSpread(true)

emitter:Emit()

How it works.

One ModuleScript, under 300 lines. No RunService loop: each particle is a GUI object with one TweenService tween, so Roblox does the animating.

  1. 01

    .new(UDim2)

    Makes an emitter with its own settings table, starting at a UDim2.

  2. 02

    :Set…()

    Setters update that table. SetAmount caps it at 100, SetColor drops anything that isn't a Color3.

  3. 03

    :Emit(n)

    Finds or creates a ScreenGui named 2DEmitter in the player's PlayerGui.

  4. 04

    Build

    One Frame, ImageLabel or custom element per particle, sized 13 + Size px.

  5. 05

    Tween

    A linear TweenService tween moves, spins, fades and shrinks it, then it's destroyed.

Using it

Require it, create an emitter, set what you need, emit.

LocalScript.client.luau
local Emitter2D = require(path.to.2DEmitter)

-- Particles start from this point on the screen.
local emitter = Emitter2D.new(UDim2.fromScale(0.5, 0.5))

emitter:Set({
	Amount = 15,
	Size = 3,
	Speed = 0.3,
	LifeTime = Vector2.new(5, 15),
	Color = { Color3.fromRGB(255, 255, 255), Color3.fromRGB(0, 255, 0) },
	Corner = UDim.new(0, 0),
})
emitter:SetParticleType(Emitter2D.ParticleType.Default)

emitter:Emit() -- or emitter:Emit(30)

The core of a particle

From module.lua. Spread decides the direction, then one tween does the rest.

module.lua
local random = math.random(Settings.LifeTime.X, Settings.LifeTime.Y)
local newPos
if Settings.Spread == true then
	newPos = UDim2.new(0, math.random(-random, random), 0, math.random(-random, random))
else
	newPos = UDim2.new(0, 0, 0, -random)
end
local tween = tweenService:Create(frame, TweenInfo.new(Settings.Speed, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {
	Position = frame.Position + newPos,
	Rotation = math.random(0, 360),
	BackgroundTransparency = 1,
	Size = UDim2.new(0, 0, 0, 0)
})
tween:Play()
tween.Completed:Connect(function()
	delay(.1, function() frame:Destroy() end)
end)

API

MethodTakesWhat it does
Emitter2D.newUDim2Creates an emitter. Particles start from this position.
:SettableSets several properties at once: Amount, Size, Speed, LifeTime, Spread, Color, Corner, ParticleType, Id.
:SetAmountnumberParticles per emit. Default 10, capped at 100.
:SetSizenumberAdded to the 13 px base size. Default 1.
:SetSpeednumberLength of the tween in seconds. Default 0.5.
:SetLifeTimeVector2Smallest and largest distance a particle travels, in pixels. Default 15 to 20.
:ToggleSpreadbooleantrue scatters particles in every direction. false sends them straight up.
:SetColor{ Color3 }Each particle picks one at random. Anything that isn't a Color3 is skipped.
:SetCornerUDimRounds the particle with a UICorner.
:SetParticleTypestringDefault (squares), Clouds (a cloud image) or Custom.
:SetIDstringWhich module in the Custom folder a Custom particle uses.
:Emitnumber?Spawns that many particles, or Amount if you leave it out.

Three particle types

  • Default

    A Frame, coloured from the Color list. One tween moves it out, spins it, fades it and shrinks it to nothing.

  • Clouds

    An ImageLabel with a cloud image. It starts at zero size, grows as it flies out, then a second tween shrinks it away.

  • Custom

    Your own module builds the element and its tweens. It can return a list of tweens to play in order, and opt in to the default tween as well.

Custom particles

Anyone could add their own particle without touching the module, by dropping a module into its Custom folder.

module.lua
-- A custom particle is a module in the Custom folder.
-- 2DEmitter calls it once per particle with the emitter's settings:
local particleElement, particleTween, particleOption = require(script.Custom[Settings.Id])(Settings)

-- particleTween can be one Tween, or a list played one after another.
-- Return nothing and the default fly-out tween is used instead.

January 2023

V2 and the plugin

Design, then generate. A Studio plugin to design a particle visually. Select a UI element, press create, and it writes a LocalScript you can edit.

New properties. Acceleration, Texture and Rotation were added. Spread was dropped for now and went on the to-do list with transparency and particle physics.

Then archived. The V2 post got 14.7K views and 55 likes. When it got outdated, I archived the repo instead of leaving people on old code.

Looking back

I wrote this in 2022. Reading it again now, this is what I'd change.

  • No pooling

    Every particle is a new Instance, destroyed 0.1 s after its tween ends. The 100-particle cap keeps that cheap, but reusing particles would cut the allocations on big bursts.

  • LifeTime is a distance

    Despite the name, LifeTime sets how far a particle travels in pixels. Speed sets how long it lives. Today I'd call them Distance and Duration.

  • Older task APIs

    It uses spawn and delay, which Roblox has since replaced with task.spawn and task.delay.

  • Edge cases in :Set

    :Set only applies values that are truthy, so Spread = false through :Set is ignored (ToggleSpread(false) works). :Emit(n) also skips the 100 cap that SetAmount enforces.

Status: archived

Finished in 2023, kept up for reference.

The code stays public so people can read it and learn from it. It isn't maintained anymore. If you want UI effects like this in your game today, I can build them for you.