Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to script NumberSequences in ParticleEmitters?

I can't seem to script any type of NumberSequences for ParticleEmitters. What am I doing wrong, and could I have an example of NumberSequence use in a script?

Here is my current code:

local plr = game.Players.LocalPlayer
local chr = plr.Character

local particleEmitter = Instance.new("ParticleEmitter", chr.Torso)

local heartsSizeSequence = "0 0.2 0 0.499452 0.3125 0 1 0.2 0"
local heartsSequence = NumberSequence.new(heartsSizeSequence)

particleEmitter.Size = heartsSequence

2 answers

✓ Accepted answer

Had this problem a while back! It's actually rather easy! The number sequence is actually expected to be in brackets using Vector3.new(0,0,0) etc! (Depending on what you have in mind)

Crunchy_Roll's method does not work for every circumstance, but it indeed does work.

Anyways, I solved it in circumstances that will work every time.

You can use an array with the values and call them in NumberSequenceKeypoint.new(time, value, envelope).

Hence:

local heartsSizeSequence = {"0", "1"}
local keypoints = {NumberSequenceKeyPoint.new(0, heartsSizeSequence[1], 0), NumberSequenceKeyPoint.new(1, heartsSizeSequence[2], 0)}

particleEmitter.Size = NumberSequence.new(keypoints)

This discussion is preserved as it was. New answers, comments, and votes are closed.