Help Needed To Remove Lag From My Game

I want to reduce lag in my game, however even after using the microprofiler, optimizing my map, etc, I still cannot find the source of the lag. I’ve joined meshes together to lower part count, I’ve tried optimizing my scripts, I switched to voxel lighting instead of future, however I stiill cannot achieve over 120 fps like I usually do.

I usually use Jailbreak as a benchmark because the map is extremely big and it looks like it would cause lag, But im getting over 120 fps consistently on it however getting less than 80 fps at times in my own game when the map is 20 times smaller.

I really need urgent help because I have a deadline for this. I have mobile and xbox support but if it lags alot then it would make no sense to include either

Heres a video of the problem

External Media

as you can see in the video, when im turned away from the map I get 100 fps, but as soon as i turn towards the map, Im averaging 70 fps

even tho its over 60 this is still concerning, because if a device averages 60 fps normally then this decrease in performance means that they would get around 30 - 40 fps insteead

7 Likes

How well did you optimise your scripts?

  • Disconnect unused connections

  • Changing some connections to :Once if they are only needed once

  • Destorying unneeded instances, like used tweens (if you aren’t going to reuse them)

  • Attempting to minimise strain on memory (things like RunService.Heartbeat, disconnecting player connections when they leave)

If you can, definitely use streaming on your maps.

6 Likes

I’ve disconnected all events thats not being used at the time
image

I’ve destroyed tweens

I’ve destroyed instances im not using
image

I’ve minimized loops and use throttling, i even lowered the frequency at which those loops operate.
However there are some important loops I cannot optimize any further

StreamingEnabled destroys my game and even when i enable it, it doesnt make much of a difference

4 Likes

Joining the meshes probably didn’t have much of an impact. I’ve never noticed part count having a sizeable impact on frame rate. I would instead try to lower to the poly and tri count of each mesh. Though, this will take more time.

3 Likes

Reduce the amount of parts in your game.

The more objects you have, the more the game has to process, render, and make calculations for. Replace some parts with textures, and added Meshes to reduce parts.

You should also disable/simplify collision where it’s not needed, because Roblox will have to calculate a complex shape, which is laggy, it its not needed, disable it.

Remove Shadows, the same idea with Collision, if it’s not needed, remove it, and if the object is very small, remove it.

Reduce the amount of lights you are using, rather than having every object have a light source, apply only one light for that whole group, as a bunch of light sources will slow down the game.

If something is not needed for the time being, remove it from workspace, and keep it in storage, so the workspace isn’t rendering something that isn’t needed

That’s likely because you’re relying too much on the client, or don’t know how to tweak it correctly (it’s pretty difficult to get right), but if done correctly, it can have good benefits.

Use it to reduce the amount of polys rendered at a time, rather than remove something entirely, which appears to be the effect you’re going for.


You’re not going to get everything how you want it, so you are going to have to make compromises to get it as close to your vision as possible. Which is a reason why optimization is hard thing to do.

3 Likes

Could you elaborate on how StreamingEnabled destroys your game? It seems like it may be your solution.

3 Likes

Almost everything in the maps collisionfidelity is box if the player cannot make contact with it, the render fidelity of every mesh is either automatic of performance, never precise,

How would I add one light for several sources?

2 Likes

Most of the effects in my game runs on the client.

External Media

if you look closely in the vid, you can see animated billboards, trees swaying (tweened), light sources, etc

all of those you see only is visible for each client and not on the server

image

so when streaming enabled is on and some screens arent rendered, when the script only renders screens at once as soon as u join the game (it doesnt constantly check for new screens) it breaks the game.

2 Likes

I highly recommend to you to read into this. It is a good way to go about detecting instances streaming in and out. It seems like your screens could be rewired to work using this.

2 Likes

Even after reading it I still dont understand, how are they setting a boolean’s brightness?

2 Likes

The microprofiler shows its just the total amount of triangles that’s the issue. There are no scripts or anything that are affecting your framerate, but you have a lot of geometry. What I see for triangle counts in your Hoops City Test vs Jailbreak, for looking away from city / at city are:

Hoops: ~940K / ~3.55M
Jailbreak: ~450K / 1.2M

In other words, your game is pushing 3 times as much geometry to the GPU as Jailbreak, with graphics manually set to max. They are using Future lighting, and a lot more custom materials though, and on the computer I tried this on just now (desktop PC with 4070) the frame rates are similar, 130-ish looking away, 80-ish looking at the densest part of the map.

I think all you can really do at this point is reduce your poly count.

3 Likes

I have a question, How did you get the tris?, I need to know because i can delete certain folders and check to see what the major issue is
image

2 Likes

Shift-Ctrl-F2 brings up the render details panel, in Studio and in the live game client. It shows the breakdown of draw calls by material, and triangle counts for geometry and shadows.

2 Likes

If i were to set models Level of Detail to StreamingMesh, do u think it would fix the problem?
image

1 Like

did you know? if you use 100 lights your game you actually get alot of lag

“overglow” as i call it is when you overlight an area. it cauzes tons and tons of lag! maybe try not using as much lights and just turning off castshadow ?

3 Likes

i really thought about that but something doesnt add up, Ive played games with many lights if not way more yet they dont cause as much lag as my game

2 Likes

What lighting techonlogy are you using? If it’s future then try changing to ShadowMap and see if that helps

3 Likes

image

2 Likes

Have you used any free scripts from the toolbox by any chance? Some may be backdoored, it seems everything has been optimized. But this might be because you’re checking your own client’s FPS which could fluctuate. Maybe you should try a live test with multiple players (Actual players by the way not just NPCs on a studio server) or also check the server’s frame rates aswell if you haven’t already, but big games like this are normal to lag. Obviously if the players are getting 1-10 fps then that’s different but the only people who will struggle are low-end device players. Which to be honest you can’t optimize those players alot, I used to have a low-end device and even games like jailbreak I would average 15-20 fps. I was a potato PC player :frowning:

3 Likes

I never ever use free models, My game isnt a big game, its not even released and its lagging, only 1 player in the server and that player that considerable lag

2 Likes