How to make a less laggy chunk system?

If you are trying to limit the amount of lag the block produces it would be recommended to limit its spawning, which is exactly what you´ve done right here.

1 Like

How come it keeps making more blocks in the same position?

--Update Chunks
			local PlayerDepth = math.floor(Humanoid.Torso.CFrame.Y)*-1
			local LayerSize = ((RowSize*2)*2)+((RowSize*2)*4)
			local Min = PlayerDepth - LayerSize*ChunkSize/2
			local Max = PlayerDepth + LayerSize*ChunkSize/2

			--Place Block
			for BlockNumber = Min,Max do
				local BlockData = MineData[BlockNumber]
				if BlockData ~= nil then
					--Check if block exists already
					local Exists = false
					for _,BlockInMine in pairs(Mine:GetChildren()) do
						if BlockInMine.Position == BlockData.BlockPosition then
							Exists = true
						else
							break
						end
					end
					
					--Place Block
					if not Exists and BlockData.BlockType ~= nil then
						local NewBlock = BlockData.BlockType:Clone()
						NewBlock.Position = BlockData.BlockPosition
						NewBlock.MaterialHealth.Value = NewBlock.MaterialMaxHealth.Value
						NewBlock.Id.Value = BlockNumber
						NewBlock.Parent = Mine
						repeat
							RunService.Stepped:wait()
						until NewBlock.Parent == Mine
					end
				end
			end