You can’t save/load terrain data directly in DataStores.
You can, however, read the terrain data via ReadVoxels and then save the returned data (the material and occupancy data tables) in a DataStore. Then, when you want to, you can load the data and use WriteVoxels to actually load the terrain into the game.
It should be noted that you can’t save Enum values (the materials table holds enum values) in DataStores directly, so you’ll need to convert the material enums to their respective string/number values and save that instead. Then, when you’re loading the saved data, you’ll need to convert those string/numbers to their respective material enums so that WriteVoxels will read the materials table correctly.
Not sure I understand the logic of saving terrain in a Datastore. I use CrazyMan32’s “Save $ Load Terrain” plugin to export my terrain, than copy the resultant save to ServerStorage. Each map change, then deletes the current terrain and loads the new in.
local SS = game:GetService("ServerStorage")
local terrains = {SS.Terrain1, SS.Terrain2, SS.Terrain3} -- A list of Terrain sources in ServerStorage
local newTerrain = math.random(1, #terrains) -- Choose a new terrain at random from the table
workspace.Terrain:Clear()
workspace.Terrain:PasteRegion(newTerrain, workspace.Terrain.MaxExtents.Min, true) -- Loads a new Terrain
Have you exported the terrain you have created using CrazyMan32’s “Save $ Load Terrain” plugin?
If you have, then you just need to make sure that the list of terrains is pointing to the right locations in this line:
local SS = game:GetService("ServerStorage")
local terrains = {SS.Terrain1, SS.Terrain2, SS.Terrain3}