My game starts to lag a lot and it takes time for a brick to even move, how can I fix this?

Hey developers, I’ve been recently working on a game for a couple of months and its almost time for it to be released to public and one thing that is preventing me from developing the game smoothly is the amount of lag, I checked my plugins and scripts, as I see theres nothing wrong with it, does anyone have a solution on how to fix this?

1 Like

How much parts/unions/meshes are in your game? When building did you accidentally duplicate an entire section? Are you sure the lag relates to your building over any scripts in the game?

1 Like

Hmmm, insufficient information about the part count but also hardware.

Could you please provide information about the game’s part count? If that is not the issue, check your hardware and provide the specs.

5 Likes

Is there a way on counting parts in a game? I haven’t tried it before, how do I do that?

I remember copying meshes and placing them to places, I know that the lag relates to my building.

1 Like

If you look up “Brick Counter” in the toolbox, you’ll most likely find a script that inserts a GUI with the amount of parts in the game. Or, you could create something similar to that - something that tallies up how much parts you have in game.

1 Like

Looking for a part counter plugin? Here’s one:

5 Likes

Just found out that my game has 2,156 parts, 39,898 voxels and 4,504 Instances.

Here is the picture of the game and how it looks like.



I just lowered my graphics so on the 1st picture it looks like the facility is halfway not on the ground, I’ll increase my graphics when the game is smooth enough

According to a post somewhere else, they stated that keeping parts below 6k is fine. Something tells me that you should get rid of unnecessary terrain voxels.

Or it is the hardware, as previously mentioned in first post of mine here.

3 Likes

Try and make a script to clean the debris.

2 Likes

There’s a few things that may be going on here:

  • You have a lot of unoptified scripts
  • You have a very large number of parts 40k+

You can always check part number in view>summary but if it’s a script issue you may have to go back and have a look at some of your scripts.

True, I’ll go ahead and get rid of unnecessary terrain voxels and I will see what happens, thanks!

The things you listed aren’t in the game, as Operatik said, I will get rid of unnecessary terrain and I will see what happens.

If you try making lots of parts a union instead of a group, it will often help (Eg terrain or walls)

I’ll try to find a clean script if Operatik’s idea is false.

1 Like

Hmm, even when I get rid of the terrain it still gives me lag. It’s pretty crazy because I have done many stuff on other games and nothing came wrong.

1 Like

I have a guess that it is physics involved, any unanchored parts or anything?

If not, try deleting a model at a time and see what is the most laggy of them all. Maybe this will pinpoint the issue. Make sure you save the initial version or else you’ll lose the creations.

In addition, it is possibly the hardware or that you’ll need to restart Studio once.

3 Likes

This once happened to me, and I found out it was because I had a while true do script without a wait, so the game was extremely laggy to the point I even crashed. Check for stuff like this.

If there were infinite loops that loop at an extremely high rate, it can cause lag, just like my procedural terrain generator…
image

1 Like