Loops local vs server

What’s more efficient and less likely to cause lag?

  1. Local loop that fires a remote function ever 0.05 seconds

  2. Server loop that runs until it is told not to and is running every 0.05 seconds

I’m pretty sure locally is better, since I just tried a test with 16 dummies each with its own while loop running at wait(0.05) and the script performance showed more than 2% activity, which is not good apparently.

Let’s take a step back here. What are you doing that requires a loop running every 1/20th of a second. Usually your code doesn’t need to run unreasonably fast, and the intervals can be bigger. Invoking a remote function isn’t very smart either especially every 1/20th a second.

2 Likes

it’s for a machine gun tool. I’m basically trying to make a gun that repeatedly fires bullets.

Sending a signal to the server for it to toggle firing on mouse down and up should work better.

1 Like