Hello, I've recently attempted to create an infinite mining sandbox game very similar to "Mining Simulator," "Treasure Hunt Simulator,""Dig It!""Fish n' Dig," and more. During the time of my attempt, I've run into this one problem that has been preventing me from publishing the game for so much time. When I have a pickaxe equipped, I start mining to lower depths and everything seems pretty normal. Until around depth 200-300 or so, my game starts lagging excessively and the progress GUI bar at the bottom of my screen (the bar that lets me know how much progress there is left until the block I'm digging at is either broken or the value of the block lowers) starts lagging when Im holding down the pickaxe. Eventually, it starts to make the game unplayable. For a while, I thought the lag was coming from the buildup of many "OnServerEvents" being fired. I have a high-quality computer, meaning I can rule out that it's not my PC alone. Eventually, I've come to the realization that it was from an excessive amount of minable blocks in the game that is cloned on all of another minable blocks' surfaces (besides the top) when a player mines it. I only see the lag improve when I manually delete some minable blocks from the Workspace which is obviously not a viable option since it would interfere with the main gameplay and purpose of the game. The minable blocks' children do not consist of anything that would be a red-flag to lag. It only consists of string and number values to specify its durability, value, etc. I really need a answer so I would love it if someone would help me.
How would I reduce lag in duplication of blocks on Roblox?
1 answer
Are you saying that the lag comes from the fact that there are blocks spawned within each other? Say a part, within a part, and another part.. If that's the case you could simply check the bounds of the part (position that the part occupies) and make sure it's empty before spawning a block at that place.
Or are you saying that when a block is mined, all the other blocks on top of it are re-cloned on top of the new block? Why would you need to reclone it. Simply use the physics available in Roblox already to make all the parts fall down in the new place.
2 comments
It’s the 2nd one but What do you mean the physics available in roblox
I just mean that when a part gets destroyed, all the parts on top of it fall down. No need to re-clone them at their correct position.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
So, did you place all the blocks and not cloning them according to the player's depth?
@BestCreativeBoy The blocks are cloned according to the players depth