Lesson 6 of 6
VFX: particles, beams, trails, lighting effects
Roblox visual effects from Beacon Yard's real code, covering particle emitters, bursts, beams, trails, attachments, lights, post-processing, flipbooks and the budgets that keep phones smooth.
By the end you can
- Tune a ParticleEmitter's rate, lifetime, speed, size and transparency, and choose between a running Rate and an Emit burst
- Use Attachments with Beams and Trails, and light a scene with lights, post-processing effects and Highlights
- Estimate a particle budget, use flipbooks carefully, and keep effects cheap on phones
Before this: Audio: recording, editing, licensing, the audio graph, World building in code: MapBuilder, lighting, atmosphere
Step 1 of 12
Look at the glow above the pads
Start a playtest at m06-drone-wrench and look past the coins. Tiny sparks rise above each yellow pad, a few more drift up from the beacon crystal, and the lamp in the physics exhibit sheds slow warm motes. None of them are parts. Each is a ParticleEmitterParticleEmitterAn object that keeps spawning small images that move, change size and fade.Think of it as a sprinkler for sprites., a single object that keeps spawning small images that move, shrink and fade.
The exhibit lamp's motes, then the drill start and its lighting shift.
Transcript
- 0:05 The coin plays electronicpingshort through SoundClient.
- 0:10 LampMotes emit upward at 8 particles a second.
- 0:16 Drill start plays the victory cue and shifts ClockTime to 18.4.
motes.Name = "LampMotes"
motes.Rate = 8
motes.Lifetime = NumberRange.new(1.4, 2.2)
motes.Speed = NumberRange.new(0.3, 0.9)
motes.SpreadAngle = Vector2.new(12, 12)
motes.LightEmission = 0.45
motes.EmissionDirection = Enum.NormalId.Top
motes.Acceleration = Vector3.new(0, 0.4, 0)
motes.Size = NumberSequence.new({
NumberSequenceKeypoint.new(0, 0.2),
NumberSequenceKeypoint.new(1, 0.05),
})
motes.Transparency = NumberSequence.new({
NumberSequenceKeypoint.new(0, 0.25),
NumberSequenceKeypoint.new(1, 1),
})
motes.Color = ColorSequence.new(Color3.fromRGB(255, 214, 150))
motes.Parent = lamp
LampMotes has Rate 8 and a Lifetime between 1.4 and 2.2 seconds. About how many motes are alive at once? Use the average lifetime.
Step 2 of 12
What each property does
An emitter spawns particles inside its parent part's volume, or at an Attachment's point, and sends them out of the face named by EmissionDirection1. The properties fall into three groups:
- How many:
Rateis particles per second. A single emitter can create up to 400 per second, or 100 on mobile. - How long and how fast:
Lifetimeis a range in seconds, capped at 20.Speedis a range in studs per second.SpreadAnglewidens the cone,AccelerationandDragbend and slow it. - How it looks:
Texture,Color,LightEmission(how much it glows), andSizeandTransparency, which are sequences: curves over the particle's life. The lamp's motes start at size 0.2 and 25 percent transparent and end at size 0.05 and invisible.
Match each change to the property that makes it.
Step 3 of 12
Bursts: Emit instead of Rate
A running Rate is right for ambience. Feedback wants a burst: twelve sparks at once, then nothing. At m07-feel, Beacon Yard adds VfxClient, which builds a hidden anchor part where something happened, gives it an emitter with Rate = 0, calls Emit(count) once, and lets Debris remove the part after the last spark fades.
local emitter = Instance.new("ParticleEmitter")
emitter.Texture = SPARK_TEXTURE
emitter.Color = ColorSequence.new(style.color)
emitter.LightEmission = 1
emitter.Rate = 0
emitter.Lifetime = NumberRange.new(LIFETIME * 0.5, LIFETIME)
emitter.Speed = NumberRange.new(if reduced then style.speed * 0.3 else style.speed * 0.6, style.speed)
emitter.SpreadAngle = Vector2.new(180, 180)
emitter.Drag = 4
emitter.Size = NumberSequence.new({
NumberSequenceKeypoint.new(0, style.size),
NumberSequenceKeypoint.new(1, 0),
})
emitter.Transparency = NumberSequence.new({
NumberSequenceKeypoint.new(0, 0),
NumberSequenceKeypoint.new(1, 1),
})
emitter.Parent = anchor
anchor.Parent = workspace
local count = if reduced then math.max(1, math.floor(style.count * Config.VFX_REDUCED_SHARE)) else style.count
emitter:Emit(count)
Debris:AddItem(anchor, LIFETIME + 0.5)
The counts live in Config: 14 sparks for a coin, 18 for a hit on the drone, 10 when the wrench reaches its Impact frame. With reduced motion on, each burst keeps 30 percent (VFX_REDUCED_SHARE) and the sparks move slower. The bursts run on the client, because the server already told this player what happened on the Feedback remote.
A player with reduced motion picks up a coin. How many sparks does VfxClient emit? (count = max(1, floor(14 * 0.3)))
Step 4 of 12
Attachments, beams and trails
An AttachmentAttachmentA point with an orientation, stuck to a part, that other objects can use as an anchor.Think of it as a pin with an arrow, fixed to a part. is a point with an orientation, stuck to a part. On its own it draws nothing. Effects use attachments as anchors:
- A Beam draws a textured strip between
Attachment0andAttachment1.CurveSize0andCurveSize1bend it into a curve,Segmentssets how smooth the curve is, andFaceCamerakeeps it facing the viewer2. Use it for lasers, ropes of light, a tether from the drone to its target. - A Trail draws a ribbon behind two attachments as they move; the distance between them is the ribbon's width, and
Lifetimeis how long it lingers3. Use it for a sword slash, or the head of Beacon Yard's wrench.
Go deeper Why a Trail needs two attachments
A trail is a ribbon, so it needs a width as well as a length. The distance between its two attachments is the ribbon's width, and the path they travel is its length. Attachments that sit closer together make a thinner trail.
You want a short glowing arc behind the wrench head while it swings. Which effect fits?
Press 1 to 4 to choose, Enter to check.
Step 5 of 12
Light, post-processing and highlights
Light is the biggest effect in the yard. MapBuilder puts a PointLight on the beacon pedestal, the shop and each sign; the exhibit lamp's light has Brightness 1.4 and a Range of 14 studs. A PointLight shines in every direction, a SpotLight in a cone, a SurfaceLight from one face4.
On top of the lights sit post-processing effects under Lighting: BloomEffect makes bright things glow, ColorCorrectionEffect shifts contrast and tint, SunRaysEffect and DepthOfFieldEffect do what their names say5. WorldLook adds an Atmosphere, a bloom and a colour correction for the dusk look, and the drill moves ClockTime to 18.4.
A Highlight outlines a model through walls. The drone has one, StunHighlight, which turns on only while it is stunned. Each client draws at most 255 highlights; past that they are silently dropped6. A disabled Highlight still holds one of those slots, so in a crowd of drones remove the Highlight instead of toggling Enabled.
A teammate wants a Highlight on every coin so players spot them. Why is that a poor idea?
Press 1 to 4 to choose, Enter to check.
Step 6 of 12
Flipbooks
A flipbook is one texture holding a grid of frames, played in order over a particle's life, so each spark can be a tiny animation such as a puff of smoke or an explosion. The layout is 2×2, 4×4, 8×8 or a custom grid; a 1024 by 1024 image in an 8×8 layout gives 64 frames. FlipbookFramerate goes up to 30 frames per second, and FlipbookMode picks Loop, OneShot, PingPong or Random1.
Flipbooks cost memory. When a device runs low, the client switches flipbooks off automatically, which is likely on older phones. Use a few, at the smallest texture that still reads, and leave spacing between frames so mipmaps do not bleed one frame into the next.
Go deeper What fill-rate means
Fill-rate is how many pixels the GPU has to colour each frame. A few large, transparent particles that overlap can cost more than many small ones, because each overlapping layer is drawn again. Keep particles small, and give flipbook textures only as many pixels as the effect needs.
A flipbook uses the Grid4x4 layout in OneShot mode on particles that live 0.8 seconds. How many seconds is each frame shown?
Step 7 of 12
A budget for particles
Particles cost twice. Each one is drawn, and overlapping transparent particles make the GPU draw the same pixel many times, which is called overdraw. Big particles cost more than many small ones because they cover more pixels, which the docs call fill-rate1. Phones feel this first.
A simple budget is "particles alive at once", rate times average lifetime, summed over every emitter you can see.
About fifty small, faint motes is a light load for the whole yard. A single explosion with a rate of 400 and a lifetime of 2 seconds would be 800 on its own, which is why bursts use Emit with a small count.
An emitter has Rate 300. What happens on a phone?
Press 1 to 4 to choose, Enter to check.
Step 8 of 12
Effects that follow the round
The lamp's motes could get busier during a drill. The server already writes the phase on a AttributeAttributeA named value you attach to any instance with SetAttribute and read with GetAttribute.Think of it as a sticky note on an instance.: Workspace.RoundPhase. Any script can listen for it to change and set the emitter's Rate.
An attribute is a sticky note on an instance. RoundService writes "Active" on Workspace's note, and every script that cares reads it. The lamp does not need to know RoundService exists.
Think of it as Sticky notes on an instance
Both sidesRemember: Attributes is sticky notes on an instance.
The note picture breaks in two ways. A sticky note can hold anything you write; an attribute holds only some types (strings, numbers, booleans, Color3, Vector3 and a few more, never a table or an Instance). And a note written on the server is copied to every client, but a note a client writes stays on that client.
Where does it break?“Sticky notes on an instance” is a good picture of attributes. Where does it stop being true?
It breaks here. Notes only travel down: a client that writes a note changes its own copy and the server never sees it; and only a few value types fit on a note.
The true model. Attributes are typed key-value pairs on an instance. Server writes replicate to clients; client writes stay local. They suit small state such as a phase or a health value, not tables or instances.
A LocalScript sets Workspace's RoundPhase attribute to "Active". What happens?
Press 1 to 4 to choose, Enter to check.
Step 9 of 12
How studios make effects
Other ways pros do this
| Option | What it is | When pros pick it | Trade-offs |
|---|---|---|---|
| Tune in Studio by hand | Insert emitters, beams and lights in the editor and adjust them live. | Ambient effects that never change, artists who are not scripters. | Lives in the place file; harder to review and reuse. |
| Build in code | Create effects from Luau with values in Config, as MapBuilder and VfxClient do. | Effects that respond to gameplay, or a code-first repo like Beacon Yard. | Slow to tune; you edit a number, then press Play. |
| Creator Store effects | Ready-made emitters, beams and textures from the Toolbox. | Prototypes, or a solo developer without an artist. | Check the licence and the scripts inside; common packs look like many other games. |
| Rendered flipbooks and meshes | Simulate smoke or fire in Blender or another tool, render a frame grid, use it as a flipbook texture. | Hero effects such as explosions where quality matters. | Memory cost, and flipbooks switch off on low-memory phones. |
Why does VfxClient create its sparks on the client instead of the server?
Press 1 to 4 to choose, Enter to check.
Step 10 of 12
Build along: a wrench trail
Build along
src/client/CombatClient.luau
In a playtest, select the
Wrenchtool inside your character, and inside itsHandlepart (the single partCombatServicebuilds atm06-drone-wrench) insert two Attachments 1 stud apart near the striking end.You should see Two Attachments named TrailTop and TrailBottom sit 1 stud apart on Wrench.Handle in Explorer during Play.
Insert a
Trailin the same part, setAttachment0andAttachment1to the two attachments,Lifetimeto 0.2, andTransparencyto a sequence from 0.2 to 1.You should see A ribbon follows the wrench head when you swing and fades within a quarter of a second.
Copy the numbers into
CombatClient.luau: create the attachments and trail from code withEnabled = false, enable the trail when the swing starts and disable it 0.25 seconds later.You should see The trail appears only during swings, not while you walk around.
Step 11 of 12
Challenges
Level 1, Apprentice
Challenge
Add a vertical beam above the beacon while the drill runs.
- Start from
- The game at milestone m06 (download)
Done means
- A Beam joins the beacon crystal to a point 20 studs above it
- It shows only while RoundPhase is Active
- It uses a texture that ships with Studio, so it needs no id
Meet the criteria above, then record your own result. No test grades this check.
Level 3, Professional
Challenge
Make the lamp's motes busier during the drill. The test is challenges/audio-vfx.luau and the solution is challenges/solutions/audio-vfx.md.
- Start from
- The game at milestone m06 (download)
- Grade it
- To grade work from an earlier milestone, apply your challenge changes to a checkout based on
m14-ship, which includes the Course Runner. In Studio, press Play, then rungame.ServerScriptService.RunGameTests:Invoke("audio-vfx", "vfx-busy-motes")in the server command bar. Copy the pass code from Output.
Done means
- LampMotes.Rate is 8 while RoundPhase is Idle or Cooldown
- It is 30 while RoundPhase is Active
- It returns to 8 when the phase is Idle again
- challenges/audio-vfx.luau prints TEST PASS for lamp_rate_idle, lamp_rate_active and lamp_rate_restored
The level 3 test shortens the round. Which test-only attributes does it set on Workspace?
Press 1 to 4 to choose, Enter to check.
Step 12 of 12
Recap
Retiring the analogy
You no longer need “sticky notes on an instance”. Attributes are typed key-value pairs on an instance. Server writes replicate to clients; client writes stay local. They suit small state such as a phase or a health value, not tables or instances.
Recap
- A ParticleEmitter's Rate and Lifetime set how many particles live at once; feedback uses Emit bursts with small counts on the client.
- Attachments anchor Beams and Trails; lights, post-processing and a few Highlights (255 per client at most) set the mood.
- Budget particles as rate times lifetime, remember the 100 per second mobile cap and the memory cost of flipbooks.
Attributes is sticky notes on an instance, until notes only travel down: a client that writes a note changes its own copy and the server never sees it; and only a few value types fit on a note.
Queued for review
- LampMotes has Rate 8 and a Lifetime between 1.4 and 2.2 seconds. About how many motes are alive at once? Use the average lifetime.
- A player with reduced motion picks up a coin. How many sparks does VfxClient emit? (count = max(1, floor(14 * 0.3)))
- A LocalScript sets Workspace's RoundPhase attribute to "Active". What happens?