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

How do I break a loop of particles in the Character's Torso?

Asked by 4 years ago

I'm trying to make a loop, but at the same time i want it to break after 10 seconds after the character spawns, so how do I do that?

Here's what I have so far:

while true do
    wait()
    script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame
    wait(10)
    if wait(10) then
        break
    end
end

script.Parent.ParticleEmitter.Transparency = 1
0
As far as i can see you want a partical emitter to go for ten seconds after the player spawns? OBenjOne 190 — 4y

1 answer

Log in to vote
0
Answered by
OBenjOne 190
4 years ago
Edited 4 years ago

What I usually do to break loops after a set amount of time is by counting the number of times the loop has run. For example,

 edited code:

 n = 0 
 while true do 
 wait (0.04)
 n = n +0.04
        script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame
 --you want to continually do this for 10 seconds right?
 if n > 10 then -- after 10 seconds
      script.Parent.ParticleEmitter.Transparency = 1

      break
 end
 end

I am not sure how long wait() is but I think it is 0.04 seconds I will check. This should run for aproximentally ten seconds I think

0
Minimum wait is arround 0.0333 so 0.04 should work OBenjOne 190 — 4y
0
And the"--do something" is the code after the loop has been broken? Hwk3rAlt 14 — 4y
0
No it is what is being repeated for 10 seconds... I will need to make some changes... OBenjOne 190 — 4y
0
I am actually a bit confused on what you want to do here but i hope this works OBenjOne 190 — 4y
View all comments (3 more)
0
Is the script inside the character? OBenjOne 190 — 4y
0
The script runs, but the particles didn't disappear, instead it broke free from the character and the particles were still going. Hwk3rAlt 14 — 4y
0
I fixed the script, thanks by the way. Hwk3rAlt 14 — 4y
Ad

Answer this question