Optimizing game with a large amount of parts

I’ve asked about this before, I still can’t figure it out though. I have a game (https://www.roblox.com/games/3588127591/Voxel-game#!/about) that consists of a very large amount of parts (3x3x3 parts). Due to this, it can lag quite a bit at times. How can I optimize it? I’ve attempted to get help before, but I can’t really understand what people mean. Can I be pointed somewhere in the direction of a tutorial or at least some good resources? I can’t find anything.

1 Like

I can’t give you direct code, but I can tell tell you the process. (I have done this in the past to support 300,000 part servers).

On the client, take the parts and divide them into chunks of 16 by 16 parts (48 x 48 studs in your case). Then, parent the chunks to workspace if they are within x studs of your character and parent them to nil if they are past that x studs.

This has worked to support 300,000 4 by 4 by 4 studs cubes in my testings.


That’s the thing though, I don’t really understand how to do that. How would I divide them into chunks, get their distance, etc.?

Each chunk should be named by it’s center x, y, and z. Simply do a magnitude check every time the player’s current chunk changes.

I’m not sure if this will work for your scenario but before making a complex chunk system you should try setting Workspace.StreamingEnabled to true and messing around with the Workspace.StreamingMinRadius and Workspace.StreamingTargetRadius values

1 Like

Would you by any chance know of any particularly good values for them? I’ve attempted it before but I dislike how I can’t see that far when I set it, though it definitely isn’t out of the picture.

No idea but as I said you can always mess around with the StreamingMinRadius and StreamingTargetRadius
If you can’t see far enough, you can try increasing both of them

StreamingEnabled is typically regarded as finnicky and I wouldn’t go for it, especially if your workspace is dynamic. A dynamic workspace allows you to control flow better anyway since you can choose when to spawn in blocks and whatnot.

A good reference to make are games that include mining or digging. Parts aren’t generated in a certain shape and then generated the same way downward, it’s done on the client. There’s a single layer and as you break blocks, a surrounding layer of them are generated.


Now I’ve never attempted the chunk method before but if you do decide to go that route, REALTimothy0812 explains it well. It is the same as how Minecraft loads chunks based on your render distance settings.

If you want it to be more nuanced, you could add a “value” to each chunk that tells you how many parts are in it; this way, your game can adapt to allow a larger render distance for areas that do not have many parts, while compensating when there are many parts. It may need some testing to find the right algorithm, but in theory it should work.

Hope this helps

Think creative: How Minecraft does this?

Well it uses chunk system. You only need to group those parts and then put the models where
you want in your workspace. Then you’ll only need a script that has a variable local renderDistance = RENDERDISTANCE_IN_STUDS and then implement a loop that checks if you
are further away from a chunk than the render distance is. And then use simple loop that parents every chunk you don’t see to nil.

I would also add a fog so it will look a bit smoother (kinda like Minecraft Bedrock Edition has fog and it looks better because the render distance is not so square)


I haven’t done this yet, but I will use what you said most likely.