ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. createParticleEmitter

Function

createParticleEmitter

Server and clientParticlesTrilogy Hub only

Creates an emitter of moving particles simulated by the game: fire, smoke, sparks, snow, portals and anything you build from the settings. The fourth argument is a preset name or a settings table, the fifth overrides chosen fields of the preset. Returns a "particle" element that can be moved, attached and destroyed like any other. Called on the server, it creates an emitter every player sees.

Syntax

element createParticleEmitter(float x, float y, float z, string|table settings [, table overrides = nil])

Arguments

xfloat
Position X.
yfloat
Position Y.
zfloat
Position Z.
settingsstring|table
A preset name ("fire", "smoke", "sparks", "fireflies", "snow", "rain", "magic", "vortex", "confetti", "hearts", "bubbles", "leaves", "dust", "firework") or a settings table.
overridestable, optional = nil
Fields that replace the preset's settings.

Returns

The emitter or false for bad arguments.

Example

A campfire next to the player and a custom portal from a settings table. All fields are described in the Particles guide.

local x, y, z = getElementPosition(localPlayer)
local fire = createParticleEmitter(x + 2, y, z - 1, "fire", { rate = 60 })

local portal = createParticleEmitter(x - 4, y, z, {
    sprite = "glow", shape = "ring", radius = 2,
    rate = 120, max = 300, life = { 1, 1.6 },
    orbit = 3, attract = 0.6, size = { 0.25, 0.05 },
    colors = { tocolor(120, 200, 255), tocolor(160, 90, 255, 0) },
})

Notes

Physics on the game side. The game simulates and draws the particles of all emitters in one pass, so the script does nothing per frame.

See also