What way can you run 2 loops at same time?

So I have 2 functions which 1 is a loop, this loop needs to ongoing through the entire time of lets say 5 seconds. I also have another function which is not a loop function meaning it runs normally, the loop function has to come first but if I do that then 2nd function will not perform.

Is there any way to make the script ignore the while loop function and after about 3 seconds perform the 2nd function?

coroutines I THINK im not quite sure tho

You’re going to want to use coroutines, it’s the best solution for what it seems you’re trying to get at. There are many YouTube and DevForum tutorials on how to use this. I think you can also use spawn() but I’ve never really tried that.

https://developer.roblox.com/zh-cn/articles/Beginners-Guide-to-Coroutines

2 Likes

You could use coroutine s to achieve this. Coroutine is a whole library, meaning there are multiple things to it. Coroutines are able to create new threads, meaning yields won’t be propagated.

Spawn is also an alternative, although too many threads created with spawn will cause latency. As addressed in eveara’s article.