How to tween transparency of multiple ParticleEmitters? (Using for loop)

I want to know how developers transparent multiple particles using TweenService.

It seems that I can’t transparent multiple effects, because you can’t tween NumberSequence.
I don’t know how to do it, so I basically just did destroy on the part and it’s not good at all, that’s why I’m trying to understand how people are doing it.

I found only how to tween transparency of one ParticleEmitter on the Developer Hub (using NumberValue), but what if I want multiple effects to appear at some point and then they fade out smoothly?

For example, here is my script that I currently have: I start an animation, then the sound starts playing and then the Red Ball is appearing in my hand. After that an explosion appears, that includes multiple effects and it fades away after like 2 seconds. How to tween transparency of multiple ParticleEmitters?

2 Likes
local ParticleEmitter = -- Path To PE
local TweenInfo = -- TweenInfo.new(Dura,Style,Dir,Repeat,Backwards,Delay)
local TS = -- TweenService

local NumVal = Instance.new("NumberValue")
local Tween = TS:Create(NumVal,TweenInfo,{Value = --[[Transparency]])
NumVal.Changed:Connect(function()
    ParticleEmitter.Transparency = NumberSequence.new(NumVal.Value)
end)
Tween.Completed:Wait()
NumVal:Destroy()
1 Like

Here’s what I wrote:


and this is the error:

Sorry, I’ve been trying to get it right for 50+ minutes and I don’t get it.

1 Like

First of all there is no reason to parent the numbervalue and second why are you doing just TweenInfo. Add stuff to it. Maybe thats the issue? Also can you show me what line is 50?

1 Like

Does local TweenInfo not work? And the line 50 was NumberValue.Parent = ParticleEmitter

1 Like

Oh the issue is I showed you as in one instance. You were suppose to figure out how to make it into a table but ill show you:

local ParticleEmitter ={} -- PE table
local Dura = 2
local TweenInfo = TweenInfo.new(Dura)
local TS = game:GetService("TweenSerivce")

for i,v in pairs(ParticleEmitter) do
    local NumVal = Instance.new("NumberValue")
    local Tween = TS:Create(NumVal,TweenInfo,{Value = --[[Transparency]])
    NumVal.Changed:Connect(function()
        v.Transparency = NumberSequence.new(NumVal.Value)
    end
    game:GetService("Debris"):AddItem(NumVal,Dura)
end
3 Likes

This is because you’re doing ParticleEmitter = blahblah:GetChildren()- that is not an Instance. That is a table of objects inside the object you’re referencing.

Are you intending to call GetChildren on the ParticleEmitter?
If so, maybe iterate through the table of objects and apply the Transparency like so:

NumberValue:GetPropertyChangedSignal("Value"):Connect(function()
for _,particle in pairs(ParticleEmitter) do
particle.Transparency = NumberSequence.new(NumberValue.Value)
end
end)

sorry for the weird indentation.

post above beat me to it

2 Likes

Thank you very much! I did it.

1 Like

Thank you, with your code I was able to figure out some stuff too.

1 Like

No probs, I forgot you mentioned multiple and not only one.

1 Like

No problems at all, thank you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.