Trying to tween a particleEmitter's Size (NumberSequence)

Hey devs!

I’m making a wind spell and I’m using a particleEmitter.

I would like to increase the size of the particleEmitter.

My numberSequence looks like that :

This is the start:

this is the end :

I want to increase the last “Ping” ( the red square) to the max size with a tween.

Is it possible? How can I do this?

2 Likes

Actually I dont find tweening neccessary for this but you can just do tween normally unless you do Size = NumberSequence.new

I already tried but I got an errormessage in the output :
This data can’t be tweened :confused:

Well then it means you cant resize it by using a tween, you should use the normal number sequence (Number sequence is literally tweening)

TweenService doesn’t support NumberSequences, as shown on its wiki page. You would have to manually loop to increment the second number of the NumberSequence.

10 Likes

You may tween NumberSequences using NumberValues, by utilizing their Changed event.

    local START, END = 0, 1

    local emitter = workspace.Orb.ParticleEmitter
    local kpValue = Instance.new("NumberValue")
    kpValue.Value = START
    kpValue.Parent = emitter

    kpValue.Changed:Connect(function(val) --Fire whenever kpValue.Value changes.
        emitter.Size = NumberSequence.new({
            emitter.Size.Keypoints[1],
            NumberSequenceKeypoint.new(1, val) --Assign kpValue.Value to this keypoint.
        })
    end)

    local tween = TweenService:Create( --Tween kpValue's Value.
        kpValue,
        TweenInfo.new(3),
        {Value = END}
    )

    tween.Completed:Connect(function() --Once completed, call Destroy() to clean up.
        kpValue:Destroy()
    end)

    tween:Play()

You can tween any NumberSequence using NumberValue. The Changed event grants you the current value, which you can then apply to the NumberSequence.

Then it’s just a matter of changing the NumberValue’s value, which we can do with a tween!

9 Likes

How much inefficient can this be?

6 Likes