How can I run a while true loop without a yield involved?
Edit: I want to run a while true loop infinitely, with code that still runs after the while true loop. I'm not having problems with exhausting the script.
If I understand correctly, you can't yield a loop until it's done. This is why you must run it in a different thread. There's two common ways of doing this, one being
spawn(function() -- code here end)
And the other being
coroutine.wrap(function() -- code here end)()
There are both slightly different but will run in different threads allowing you to run loops and continue to run code after it without yield from the loop. I prefer coroutine when doing something that must be exact because I think it runs immediately, not too sure though, other than that I use spawn.
Hope this helps :3
Always include a delay such as wait() inside an infinite loop, as omitting it can freeze the game. Please read the article about loops Here