How do I find out where my lag is coming from?

I keep having these two lag spikes in my game, I don’t know what script is causing them and I don’t understand what micro profiler is telling me.


Also when these who lag spikes do appear there is no change in script activity that’s noticeable / out of the ordinary. Any help would be appreciated.

First what does the process says? For example if it says process, that means our CPU is trying to render a lot of BaseParts at your current camera.

Whenever I disabled my scripts the lag spikes go away so I’m 100% certain that its not a render BasePart problem.

Then it is something with your scripts. How much scripts is there in your game?

Theres a lot but i do know which script exactly is causing the lag (when its disabled lag goes away) the problem is that the script has 2000 lines so its still hard finding which area of the script is causing all the lag.

It doesn’t mean which script is causing the lag. Having too much threads AKA scripts in your game can affect server performance.

Well the overall server performance seems fine its just i randomly get these double lag spikes even when nothing important in the game just happened

That’ll still cause server performance, as the server has to run multiple scripts at once.