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
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