How Do I Fix Tiny Lag Spikes?

Hello. Recently I’ve been working on a cafe game for my friend’s group. I’ve had a few lag issues.
When the server is new, for about 15 minutes there’s no lag whatsoever, but then gradually, lag spikes begin to occur. They happen every 2 to 10 seconds-ish, and the MicroProfiler says they last about a quarter second each (which is pretty much what I remember it being like).
As time goes on, these lag spikes gradually get worse, to the point that the game is unbearable to play.

A mobile user claims the lag is too bad to play. I have a nice i3 and GTX 1660, so it’s not game-breaking for me.

How do I determine what’s causing this lag??? I just want to know what scripts are doing this. The game has zero moving parts (other than the players, of which there are rarely more than 5 at once).

Micro profiler:
image

probably a while loop, inside a while loop without breaking, most of times is because of bad programming, check your codes, and loops.

2 Likes

I have tons of scripts, and many of them are very old. Is there a tool that will help me determine the cause of the lag? I’d prefer to not have to go through and check each script.

just do ctrl + shift + f and search “while”

Ok here’s something I just realized.

The spikes occur every time someone sends a chat message.

Any help?

Is there a script a script that get triggered when people chat? Like a plr.Chatted function or something?