Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Any way to make particles transparent with a for i loop?

Asked by 5 years ago

You know how you can make parts transparent with a for i loop? Is there a way to do the same with ParticleEmitters? I tried

for i = 1, 20 do
PE.Transparency = NumberSequence.new(0.2,0.5)
wait()
end

and other things like that. Any suggestions?

0
please properly indent your code User#21908 42 — 5y
0
indenting doesnt matter? ScrubSadmir 200 — 5y
0
It matters when you want others and yourself to properly read it. xPolarium 1388 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

That is quite a simple method you can do. You could do this just as simple:

for i = 0, 1, .1 do
PE.Transparency = i
wait()
end

I'll give some background into the code. "i" will represent the starting point of the transparency which will be 0. The number 1 will represent the desired number you would like to reach. Then .1 will represent the number increment so each time it will go up by .1. As an example: .1, .2 ,.3, .4, .5, .6, .7, .8, .9, 1 and stops at 1.

0
please properly indent your code. User#21908 42 — 5y
Ad
Log in to vote
0
Answered by
xPolarium 1388 Moderation Voter
5 years ago
Edited 5 years ago

ParticleEmitters and Trails both take NumberSequences for Transparency.

Looking at RobloxDev on NumberSequences:

NumberSequence.new ( number n )

Using this we can count up towards 1 until the particle emitter is completely invisible.

local PE = script.Parent:WaitForChild("ParticleEmitter")

for i = 0, 1, .05 do
    PE.Transparency = NumberSequence.new(i)

    wait()
end

This loops from 0 to 1 with an increment of .05 every 1/30 a second.

0
I completely overlooked that it was a ParticleEmitter. GetGlobals 343 — 5y

Answer this question