Reading & Writing Terrain

Hello, how would I use Terrain:ReadVoxels() and a loop to loop through all of the games terrain in a region say,

local wholeRegion = Region3.new(Vector3.new(-100,-100,-100), Vector3.new(100,100,100))

and save the result of local materials, occupancies = terrain:ReadVoxels(region, 4) to a table which can later loaded using terrain:WriteVoxels()?

What I’m basically trying to do is best summarized in this post/quote:

I have tried looping through the regions x,y,z with a for loop but I don’t know how I would make sure each region isn’t large enough (more than 10x10x10 array).

I am unable to use terrain regions for my specific situation since they aren’t replicated to the client.

Any help is appreciated!

Sadly it is very challenging to do this.
You must keep track of how much space all terrain takes up because roblox provides no way to see where all terrain is located. This is because :ReadVoxels only allows us to read a chunk of the world, rather than the entire thing.
Terrain has a .MaxExtents property, but that only tells us the maximum possible space.
I’ve tried looping through all possible chunks to read terrain before, but even with absolutely no terrain it takes a few seconds for the code to search all that space.

I have no solution because any solution I could provide would rely on certain expectations of how terrain is loaded & other things. :frowning_face:

Summary: roblox terrain is not the most thought-through system