Scripting
The plugin does not run in the game. In the game, a script plays the effects through a ModuleScript named Part_Icles. The plugin keeps that module in ReplicatedStorage.
Exercise 17 introduces the module step by step. Exercise 18 plays an effect at a chosen place. This page lists every call. The pages of this section describe each call in full.
The three lines
Section titled “The three lines”Every script that fires an effect starts with these lines.
local Part_Icles = require(game.ReplicatedStorage:WaitForChild("Part_Icles"))Part_Icles:Activate()
Part_Icles:AbsoluteEmit(workspace:WaitForChild("Explosion"))| Line | What it does |
|---|---|
local Part_Icles = require(...) | Loads the module. |
Part_Icles:Activate() | Starts the module. It is needed once on each machine where a script fires effects. |
Part_Icles:AbsoluteEmit(item) | Fires item, as the Emit button of the HUD does. |
The scripts of this section are LocalScripts. Effects must be fired from a LocalScript, not from a server Script. To show one effect to every player, the server calls FireAllClients on a RemoteEvent, and each player’s LocalScript fires it. Getting the module into a script gives the reason. Worked scripts gives both scripts.
What “Absolute” means
Section titled “What “Absolute” means”Two words are used on every page of this section. A stock emitter is a ParticleEmitter, Trail or Beam that the plugin has not transformed. A container is a Folder, Model, Part or Attachment that holds emitters.
A call without Absolute in its name acts on one emitter.
A call with Absolute in its name acts on the item and on everything inside it. It accepts an emitter, a stock emitter or a container.
| Absolute call | Does this |
|---|---|
AbsoluteEmit | EnableEmit for every emitter found. |
AbsoluteEmitAt | EnableEmitAt for every emitter found. The layout of the effect is kept. A Folder is not accepted. |
AbsoluteEnable | Switches every emitter found on, with no end. |
AbsoluteDisable | Stops every emitter found. Particles in flight finish. |
AbsoluteSetTimescale, AbsoluteClearTimescale | The timescale call for every emitter found. |
Two calls without Absolute in the name also act on everything inside the item: Disable and SoftDisable.
AbsoluteDisable and Disable are different kinds of stop. AbsoluteDisable lets particles in flight finish. Disable removes them at once. To clear a whole effect at once, call Disable on its container.
Every call
Section titled “Every call”In the tables, item is an instance. A ? after a name marks a value that may be left out. A call gives nothing back unless the table says otherwise.
Starting the module
Section titled “Starting the module”Covered in Getting the module into a script.
| Call | Takes | Gives back | What it does |
|---|---|---|---|
Part_Icles:Activate() | Nothing | Nothing | Starts the module on the machine where the script runs. |
Part_Icles:Deactivate() | Nothing | Nothing | Stops the module and removes everything it made. |
Firing
Section titled “Firing”Covered in Firing an effect.
| Call | Takes | Gives back | What it does |
|---|---|---|---|
Part_Icles:AbsoluteEmit(item) | An emitter, a stock emitter or a container | The seconds until the effect has finished. nil if some part never ends. | Fires everything in item once. Each emitter uses its own Emit count, Delay and Duration. |
Part_Icles:EnableEmit(item, link?) | One emitter. An instance to link to. | Nothing | Fires one emitter once, with its own Emit count, Delay and Duration. |
Part_Icles:Emit(item, link?) | One emitter. An instance to link to. | Nothing | Makes exactly one particle, now. |
Part_Icles:EmitAnimate(item, link?) | One emitter. An instance to link to. | Nothing | Starts one Animate cycle, now. |
Part_Icles.await(seconds) | A number of seconds | Nothing | Waits that long. It is written with a dot. |
Firing at a place
Section titled “Firing at a place”Covered in Firing an effect at a place.
| Call | Takes | Gives back | What it does |
|---|---|---|---|
Part_Icles:EnableEmitAt(item, origin, options?) | One emitter. A CFrame, a Vector3 or an instance. A table of options. | A play handle, and the seconds the play takes | Plays one emitter with its particles starting at origin. |
Part_Icles:AbsoluteEmitAt(item, origin, options?) | An emitter, a stock ParticleEmitter, or a Part, Model or Attachment that holds emitters. Then as above. | A play handle, and the seconds the play takes | Plays everything in item at origin. |
handle:Wait() | Nothing | The seconds waited | Waits until this play is over. |
handle:SoftDisable() | Nothing | Nothing | Stops this play making particles. Those in flight finish. |
handle:Disable() | Nothing | Nothing | Stops this play and removes its particles at once. |
handle:SetTimescale(scale, duration?, permanent?) | A speed. Seconds. true for no end. | Nothing | Sets the speed of this play’s particles. |
handle:GetParticles() | Nothing | A list of instances | Gives the particles of this play that are in flight. |
handle:GetPDatas() | Nothing | A list of tables | Gives the module’s own records for those particles. Their layout can change with any version. |
handle:IsAlive() | Nothing | true or false | Says whether this play still has particles or is still making them. |
handle.Active | A value, not a call | true or false | The same answer as handle:IsAlive(). |
handle.Duration | A value, not a call | Seconds, or nil | The length of this play. nil means it never ends. |
Starting and stopping
Section titled “Starting and stopping”Covered in Starting, stopping and waiting.
| Call | Takes | Gives back | What it does |
|---|---|---|---|
Part_Icles:Enable(item, link?, duration?) | One emitter. An instance to link to. Seconds. | Nothing | Streams particles at the emitter’s Rate while its Enabled is on. |
Part_Icles:AbsoluteEnable(item) | An emitter, a stock emitter or a container | Nothing | Switches everything in item on and leaves it on. |
Part_Icles:Disable(item) | An emitter or a container | Nothing | Hard stop. Stops everything in item and removes its particles at once. |
Part_Icles:SoftDisable(item) | An emitter or a container | Nothing | Soft stop. Stops everything in item. Particles in flight finish. |
Part_Icles:AbsoluteDisable(item) | An emitter, a stock emitter or a container | Nothing | Soft stop for everything in item, stock emitters included. |
Covered in Speed.
| Call | Takes | Gives back | What it does |
|---|---|---|---|
Part_Icles:SetTimescale(item, scale, duration?, permanent?) | One emitter or one stock ParticleEmitter. A speed. Seconds. true for no end. | Nothing | Sets the speed at which the emitter’s particles run. |
Part_Icles:ClearTimescale(item) | One emitter or one stock ParticleEmitter | Nothing | Removes that speed. |
Part_Icles:AbsoluteSetTimescale(item, scale, duration?, permanent?) | An emitter, a stock ParticleEmitter or a container. Then as above. | Nothing | Sets the speed for the item and for every emitter and stock ParticleEmitter inside. |
Part_Icles:AbsoluteClearTimescale(item) | An emitter, a stock ParticleEmitter or a container | Nothing | Removes the speed from all of them. |
Covered in Links.
| Call | Takes | Gives back | What it does |
|---|---|---|---|
Part_Icles:SetLink(item, target, mode?) | One emitter. An instance, the text "camera", or nil. A Link Mode as text. | Nothing | Changes the emitter’s own Link, for every later firing. |
Part_Icles:SetEmitParent(item, parent) | One emitter. An instance, or nil. | Nothing | Changes the emitter’s Emit Into. |
Part_Icles.LinkService:Activate() | Nothing | Nothing | Starts the link service. |
Part_Icles.LinkService:Deactivate() | Nothing | Nothing | Stops the link service and ends every link. |
Part_Icles.LinkService:Link(part, target, mode?, duration?) | A Part, Model or Attachment. The instance to follow. A mode as text. Seconds. | Nothing | Makes part follow target. No particles are involved. |
Part_Icles.LinkService:Clear(part) | The linked instance | Nothing | Ends its link. |
Part_Icles.LinkService:IsLinked(part) | An instance | true or false | Says whether it is linked. |
Textures
Section titled “Textures”Covered in Textures.
| Call | Takes | Gives back | What it does |
|---|---|---|---|
Part_Icles:Preload(root, force?) | An instance. true to include every emitter. | Nothing | Keeps the textures of the emitters under root loaded. |
Part_Icles:Deload(root, force?) | An instance. true to include every emitter. | Nothing | Releases what Preload held. |
Limits and helpers
Section titled “Limits and helpers”Covered in Limits and helpers.
| Member | Takes | Gives back | What it does |
|---|---|---|---|
Part_Icles.MAX_ACTIVE_PARTICLES | A value, not a call | A number. Starts at 1000. | The Particle Cap in the game. A script may set it. |
Part_Icles.Log.enabled | A value, not a call | true or false. Starts at true. | Set to false, it silences the module’s Output messages. |
Part_Icles:GetFolder() | Nothing | A Folder | Gives the folder that holds the particles in flight. |
Part_Icles:GetPoolFolder() | Nothing | A Folder | Gives the folder that holds idle particles kept for reuse. |
Part_Icles.ActiveEmits | A value, not a call | A list | Its length is the number of particles in flight. Read it only. |
Part_Icles:GetData(item) | An emitter | A table, or nil | Gives the emitter’s settings as the module reads them. Read it only. |
Part_Icles.parseDuration(value) | A number, or text such as "1, 2" | A number, or nil | Reads a Duration. Text of two numbers gives a random value between them. |
Part_Icles.Log.print(...), Part_Icles.Log.warn(...) | Anything | Nothing | Write to the Output window, unless Log.enabled is false. |
Part_Icles:Transform(item) | An instance that is not an emitter | Nothing | Turns the instance into an emitter, as the Transform button does. |
Part_Icles.TransformCompleted | A value, not a call | A BindableEvent | Its Event runs after each successful Transform, with the new emitter. |
Related pages
Section titled “Related pages”- Worked scripts: complete LocalScripts to paste and change.
- The event script and its payload: the script an emitter runs on an event.
- Property reference: the attribute name of every row.
- Nothing emits: what to check when a script fires and nothing appears.