Korniak
|
  |
| Joined: 09 Aug 2013 |
| Total Posts: 3538 |
|
|
| 13 Apr 2016 03:07 PM |
| but not wait for it to finish? |
|
|
| Report Abuse |
|
|
|
| 13 Apr 2016 03:08 PM |
of course.
while true do wait() -- repeat something forever. end |
|
|
| Report Abuse |
|
|
|
| 13 Apr 2016 03:09 PM |
Oh wait, I see what you mean.
What would be a use case for this?
You could do this:
while wait() do spawn(function() do something here end) end |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 13 Apr 2016 03:09 PM |
spawn(function() for i = 1,5,1 do print(i) end end)
|
|
|
| Report Abuse |
|
|
jode6543
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 5363 |
|
|
| 13 Apr 2016 03:15 PM |
Just throw the loop in a coroutine:
coroutine.wrap(function() while wait() do -- do stuff end end)() print("After the coroutine yields (calls wait() or any function classified as YieldFunction in the docs), it will continue running the code from the script that created the coroutine.")
Alternatively, you can throw the loop into Spawn, but be aware that the loop won't start running until the next frame.
More information: http://wiki.roblox.com/index.php?title=Function_dump/Coroutine_manipulation http://wiki.roblox.com/index.php?title=Beginners_Guide_to_Coroutines http://wiki.roblox.com/index.php?title=Threading http://wiki.roblox.com/index.php?title=Thread_scheduler |
|
|
| Report Abuse |
|
|