Game optimization

How can I optimize my game? My game crashes / lags a lot for many players

Reason why game can lag:

  1. Memory leaks - It means you forgot delete something (free memory).
  2. Hosting many players ofc will cause lags (Humanoid its very expensive object, if on 1 place more than ~40 players it will cause lags.)
  3. Infinity loops
  4. Server overloaded with useless stuff.
  5. Serversided non major scripts. (There is one rule: “Always ask yorself, should server see/do that?”

how can i find out which scripts are causing lags?

Play test the game in studio, go to the view tab and select Script Performance.

Developer Console
image
Memory will show every single object,
Scripts for their performance
Or

Lag is not an accurate descriptive term as far as the game developer is concerned. You need to narrow down which area(s) of the system are being slowed down.

Is it the render system bogging down, resulting in low FPS rates?
Is it an issue with the network replication, such as delayed updates from the server?
Are your scripts or localscripts doing a large amount of computation without yielding?

The MicroProfiler can be used to examine the duration of tasks in the various areas of the system, as well as the execution duration of your code.

Only a few things can cause a client crash. Check your Filtered Devices stats to see if the crashes are primarily happening on lower end devices. If they are, the probable culprit is client memory overflow. 407 mb for client memory is really high for a mobile user, and will easily crash older phones.

Streaming Enabled can be used to lower the client memory rate for parts in Workspace.

3 Likes