Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

As far as i can see you want a partical emitter to go for ten seconds after the player spawns?

1 answer

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

7 comments

0

Minimum wait is arround 0.0333 so 0.04 should work

0

And the"--do something" is the code after the loop has been broken?

0

No it is what is being repeated for 10 seconds... I will need to make some changes...

0

I am actually a bit confused on what you want to do here but i hope this works

0

Is the script inside the character?

0

The script runs, but the particles didn't disappear, instead it broke free from the character and the particles were still going.

0

I fixed the script, thanks by the way.

This discussion is preserved as it was. New answers, comments, and votes are closed.