Game having lag spikes without a reason

I’ve been having this problem for a while in my game now, i’ve tried a lot of things to fix it for example i optimized shadows in every model so only certain objects have shadows enabled, i put correct renderfidelity properties to meshes, i disabled cancollide for high poly meshes and replaced them with primary parts yet it still lag spikes without a reason.


This is the microprofiler lag spike section. I will appreciate any help.

4 Likes

It’s hard to see from the image. What item is causing the highest lag spike?
If it’s physics then do you have CanTouch selected false for all the parts a Touched event doesn’t need to fire on?

I’m not sure, but as soon as i move my camera to some angle it just randomly lag spikes, also pretty sure i turned it off for every part except the one that needs it but ill recheck right now.

I’ve checked and it just lag spikes whenever i turn my camera around randomly, i put everything to cantouch false except stuff that needs it and it didnt affect framerate.

Does the lagspike occur in a specific direction or is it in all directions?

Not all directions but definitely more than 1.

If you have a lot of Parts in a small area it can affect rendering and cause lag.
Try moving the camera really far away from all the Parts/MeshParts/Unions etc. and test using ‘Play here’.
Move the camera around and see if it still happens.

Do you have any scripts that are controlling the camera?

Yes, i have a custom camera movement script

Most people have lag spikes because they keep adding checks in their scripts like

Print("Gui Active")

Or anything like that, if you have to many prints looping it could cause your game to lag. I had 2 prints in a loop and it dropped over 10 fps. This may not be the problem but make sure to check this.

Disable the script to see if that’s what’s causing it.

There is always a reason for lag.

It is too abstract a question to even begin to help you with the information we have. All I can suggest is make a new place and start copying stuff into the new place, run the game as you copy more and more stuff and you might see the moment the lag starts to happen and find the culprit.

1 Like

I dont have any prints in loops in my game

Tried it, its not the script its something with the builds

And did you look for the other items I mentioned?

yeah, it does infact fix the fps as soon as i fly away far enough

So how many Parts/Unions/Meshparts do you have in that area where the fps drops?