How do I clone 262,144 parts without lag?

I’m just started the game Humanoid Fungrounds, and I’m trying to do the tiles. The tiles right now are a union with an outline. I’m trying to make roughly 262,144 of them to span across a 2048 by 2048 stud “canvas?”. Please help, any feedback is appreciated.

Tile

You could clone those parts on all clients instead of the server with the help of remote events

262,144 parts a are like… A LOT. You should try to search a better method for what you want or add a very little delay between cloning around 200-300 parts, such as 0.3 sec.

2 Likes

Look into “Greedy Meshing” as utilizing it can reduce the total numbers of parts significantly.

3 Likes

I believe the issue is, the resolution of the canvas is too big, if your goal is to create a canvas ~ then create one with the bounds of the camera, and move those objects so their always in range of the camera.

That being said, you could also render in new regions when you start heading to those regions with your camera…

Buut, my solution would be something like this.

local MAX_PARTS = 262144
local YIELD_AFTER = 100 -- 2621 iterations

for partIndex = 1, MAX_PARTS do
   if partIndex % YIELD_AFTER == 0 then
      task.wait()
   end

   spawnPart(partIndex)
end

Perhaps you should clone it in chunks, similar to Minecraft, only load in the chunks that are near players.

I sometimes do the same, But to make it simple

if Index rounded to the Increment is Index then use task.wait()

local MaxParts = 262144
local Increment = 100

for partIndex=1, MaxParts do
	if math.round(partIndex / Increment) * Increment == partIndex then
		task.wait(0.1)
	end

	spawnPart(partIndex)
end
1 Like