Is there a way to prevent loops from causing lag?

Ok so I wonder if there is a way to make loops (around 20 of them) not cause lag?
Let say it is required to have 20 different loops. I just want to know if there a way.

Optimize your scripts in a way that makes you not need 20 different loops, and just a couple

1 Like

It probably isn’t required to use 20 loops. The best way to optimize these is to use signals instead.

1 Like

I never heard of it. Can you tell me what it is? I couldnt find the page about it.

This article can help you. What I assumed is that you have loops doing and checking stuff all the time. Instead of that you can do those once when a specific signal is sent. Events | Roblox Creator Documentation

1 Like

Do they all need to run at the same time?
Use task.spawn() if so.

It all depends what you do inside of them.
Loops in general are not laggy, try optimizing your code instead.

And, having 20 loops seems unnecessary.