How to decrease lag

Does not work. it said publish failed.

Well, reinstall studio hope this works after doing it.

Reinstalled, It still does not work.

Maybe, restart your computer I don’t know lol.

I appreciate my framework being linked! However, it is not something that just makes your code not laggy. When speaking in terms of optimization, the framework seeks to encourage optimization, not just create it. This is done by the structure of things, such as integrated object-oriented programming and code-to-code communication. You can’t just put code in the framework and hope it runs faster, unfortunately.

(P.S. that tutorial is super old, PolyHall has a new series of tutorials that are phenomenal though!)


I assume the lag comes from the mass of instances you are creating. I’m also assuming that you are just creating them all with Instance.new() individually.

What minecraft does is culling. In a sense, a very large grid of invisible blocks are placed evenly across the area. When a player is within render distance, the block becomes visible, and when they walk away, it becomes invisible again. It’s not a noticeable thing, but behind the scenes it’s incredibly smart.

However, Minecraft takes it a step further. Instead of pre-creating all of the blocks for the whole map, it has a set number of blocks around them that can render. For example, if your radius is 10 blocks, then your area is 10x10, meaning you have 100 blocks that exist at maximum at all times.

In your case, instead of creating and destroying chunks, re-use existing blocks. When a block is created, have it check a table to see if any blocks are “culled,” or as you can imagine it, unused. If so, use that block instead of creating a new one.

When a block is destroyed, instead of actually destroying it, set its transparency to 1, and mark it as “culled.” Changing transparency is incredibly efficient and beats other methods of culling, such as positing far away or sizing to 0.

This is much more efficient than constant construction and destruction.

Hope this helps!

4 Likes

Thanks, this helps reduce the lag!

1 Like