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

Increasing speed of particles with a loop?

Asked by 5 years ago

How would I make a loop that increases the speed of a particle emitter every second. I'm not familiar with user data errors and what they mean but I keep getting them with this one line of code.

repeat
ParticleEmitter.Speed = ParticleEmitter.Speed + NumberRange.new(10, 10)
wait(1)
until nil

It's all one line by the way.

0
Not 100% on what your intent is with the use of NumberRange here, but try just using a primitive (ParticleEmitter.Speed = ParticleEmitter.Speed + 10, for example) to see if that works. saenae 318 — 5y
0
Unfortunately that doesn't work tygerupercut3 68 — 5y
0
It gives me the error: Workspace.tygerupercut3.LocalScript.Script:155: attempt to perform arithmetic on field 'Speed' (a userdata value). Which is why I added the number range in the first place. Any other ideas? tygerupercut3 68 — 5y

3 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

I had the same question for transparency.

for i = 1, 3 do

ParticleEmitter.Speed = NumberSequence.new(i)

wait(1)
end

I don't know your particle emitter's starting speed, so change 1 to the starting speed of it, and 3 to the speed you want it to end it. If it doesn't work, comment the error, I came up with this on the spot. What does this is the speed increases to the number i, of the for loop, is. Every second that passes, with the numbers I put, the speed increases by 1 until it reaches a speed of 3.

0
This worked! I just had to change line 1 to: for i = 1, 3, 1 do and it uses a NumberRange instead of a NumberSequence. Thank you for suggesting a for loop and setting speed to the value of i in the loop, that's the part I was missing. tygerupercut3 68 — 5y
Ad
Log in to vote
2
Answered by 5 years ago

Hello! As mentioned above, you could also do a for loop to limit the times it will go up.

for i = 1, 100, 5 do -- 1 Stands for what to start counting from, 100 stands for what to count up to, and 5 stands for how much to count with each time.
    ParticleEmitter.Speed = i
end

~Waterfoox

0
Yep. Knineteen19 307 — 5y
0
Yep. Knineteen19 307 — 5y
0
This worked, I just had to add a little piece to line 2 so it says: ParticleEmitter.Speed = NumberRange.new(i). Instead of just Speed = i. Thank you for suggesting a for loop, that's what I was forgetting. tygerupercut3 68 — 5y
Log in to vote
1
Answered by 5 years ago

I don't know, but I have a feeling you're overthinking this a little bit. If it was me, I would use a while true do loop, or if you want it to go for a set amount of times, you could do a simple for loop. Here's what I would do:

while wait(1) do -- Repeats everything between do, and end, waiting 1 second each time it finishes once.
    ParticleEmitter.Speed = ParticleEmitter.Speed + 10 -- Adds 10 to the speed every time it's ran.
end

Hope that helps!

0
The part I was missing was a for loop. Then I just set the Speed to NumberRange.new(i). As some of the other answers did. tygerupercut3 68 — 5y

Answer this question