HELP! Game is UNPLAYABLE, Insane Lag!

Hi all,

image

I’ve been working on a game with a large city and I’ve taken as much as I could the necessary measures to ensure that my game is optimized.

This is what I did so far:

  • Every part in the map has CastShadow=false and CanTouch=false

  • StreamingEnabled is set to the default settings (64, 1024, opportunistic)

  • I set the LevelOfDetail for every building to StreamingMesh

  • I set the RenderFidelity and CollisonFidelity for every meshpart to “Performance” and “Box” respectively

  • Added a fog with FogEnd=4000

But the lag persisted.

So I proceeded to the next step, which was to disable every single script in my game.

There was not much of a difference, the lag was still there.

I then concluded that the lag may have been caused by the buildings. So I removed most of the buildings just for testing and… the lag spikes were still persistent.
??? ??? ??? ??? ???
Surely the terrain can’t be that laggy, right?

The situation seemed hopeless, so I started using MicroProfiler to get the exact details about what may be causing the lag.

image
image
image
image
image


Most of these tags are related to rendering and replication issues. Perhaps it’s almost as if Streaming Enabled was causing more lag than it should prevent by loading and deleting huge chunks of buildings. But it could be something else, as I have no clue what the deserializePacket or the $Event tags mean since they are not described in detail in the documentation.

So this is what I did to battle this issue:

  • I’ve reduced the max speed for all my vehicles

I think that’s pretty much all I could do about it, but nothing changed about the lag spikes. So I’m pretty much stumped towards this issue.

The consistent lag spike is not caused by scripts, so it could not be a virus.
I’ve made sure everything is anchored, so it could not be caused by physics either.

What else am I missing? What should I try next?

Thank you in advance.

5 Likes

Im not that good at help, but if im right, fog increases your lag if im right, i used a fog model and it lagged me in roblox studio and in-game so fog might the problem, secondly try to make your map smaller or make a map and smaller.
If this helps, no need to thanks.

5 Likes

I haven’t tried this before but If I recall, you can enable the StreamingEnabled in the Workspace property making the farther objects not render and their scripts?

Check the documentation about it because I always wonder back then when I was still playing the Islands game that how the server can handle the extensive parts per base of a player and then I discover that it uses streamingenabled.

4 Likes

Possible memory leak… Do you instance a lot of things in your game?

2 Likes

You could try disabling CanCollide and CanQuery on small parts.

Also maybe the problem is the amount of billboard guis i think they can also lag, so put a max distance on them

1 Like

I was talking about the fog property on Lighting, not a model.
image

I have it enabled

There are items that spawn randomly around the map every minute, with a limit of how many items there can be at once. I don’t think that is what causes a memory leak. Also I have tried to disable most of the scripts in the game to test and the lag was still persistent.

This was already done

I only have 3 billboard guis with a really short max distance.

1 Like

There are hundreds of games that have a map much much bigger and larger than mine, yet they do not experience the same lag as I do.

Try removing the fog and checking your game

I have already experimented with the fog. Also the Microprofiler makes it very clear that the issue is not related to the fog whatsoever.

1 Like

I think the problem is the items that spawn every minute

2 Likes

That’s interesting, why do you think so?

1 Like

Maybe the map itself is the problem through a ton of unregulated CanCollide parts, although that seems unlikely… Meshes could be too detailed as well.

I’d recommend disabling every script and seeing if the lag persists. If it does, we’ll know what the issue is

1 Like

I made sure every RenderFidelity is set to Performance for MeshParts

Every part takes away a pings ms, depends how much parts are there spawning per minute

My bad.

Well this is just strange. I suppose the next step would be removing everything and replacing it with a baseplate, although that would create a lot of errors no doubt…

1 Like

If the game is public, could you link it?

1 Like

One thing that can cause a lot of lag is scripts that run a certain action binded to certain events of the Run Service. For example, connecting too many functions to the Heartbeat event , RenderStepped event, and RenderStep event, as well as any others that update extremely often, can cause a MASSIVE amount of lag. If you have any of these, consider changing them.

IIRC, If you set models to StreamingMesh, they will be the highest quality possible. So don’t do that.

I played the game and it seemed to run very well. My memory usage was about 2 gigabytes. I assume it is some sort of memory leak, which are typically cause by events that are never disconnected. For comparison I tested my memory usage on Jailbreak which seems to be about the same size as your game, and only had 1.5 gigabytes used on average.

However, it is quite interesting that disabling all scripts did not help. What happens if you delete the buildings and scripts?

1 Like

Try to make as many models as possible . Organize your workspace in such a manner that if you open the Model named In_Game, you should find various more models and inside them, more. Try to keep your explorer as clean as possible. I’ve experienced such a lag while trying to clone many things in an infinite loop with task.wait(0.5) and then found a solution to clone all of the things into a folder inside of workspace.

Try various debugging method such as removing all lighting packages and then testing game to see if lag has gone or not. If they lag is gone then there’s some issue with your lighting but if it persists then try to disable all the scripts and localscripts in your game and run the game.

If the lag still persists then there might be a problem with your building infrastructure. But if the lag has reduced after disabling all the scripts then have a quick glance through your infinite loops and shorten it as much as possible.

If your lag still persists after disabling all scripts then check for any usual nodes or rigs that you have in the workspace. I remember having a 10,000 rigs for a dummy in my workspace which made it impossible for me to spawn in game. Kindly check through all constraints such as Weldconstraint, Attachment and etc. A lot of those under one instance can cause heavy lag as well.