In the process of making a Deathrun game. Would like to create maps using Roblox’s terrain and was wondering if its possible to easily load and unload terrain in game.
Yes, this is doable you have a few options depending on how you want to structure your maps
1. ReadVoxels / WriteVoxels (i think its the best option)
Build your map in Studio, read the voxel data into a table, then write it back at runtime. You can store multiple maps this way.
local Terrain = workspace.Terrain
local region = Region3.new(Vector3.new(-512, -50, -512), Vector3.new(512, 100, 512))
region = region:ExpandToGrid(4)
local materials, occupancies = Terrain:ReadVoxels(region, 4)
Terrain:WriteVoxels(region, 4, materials, occupancies)
Heads up: ReadVoxels/WriteVoxels has a hard limit of 4,194,304 voxels per call. If your map is larger than that, split it into chunks (e.g. 100x100 stud slices) and loop through them. There’s also WriteVoxelsAsync if you want non-blocking writes.
2. CopyRegion / PasteRegion (TerrainRegion)
local savedMap = Terrain:CopyRegion(region:ExpandToGrid(4))
savedMap.Parent = ServerStorage
Terrain:Clear()
Terrain:PasteRegion(savedMap, Terrain.MaxExtents.Min, true)
Simpler if you don’t want to serialize voxel arrays yourself. Note that TerrainRegion data doesn’t replicate between server and client, so run this on the server.
3. Multiple map locations
Build every map in its own area of the world (e.g. y = 0, 1000, 2000…) and teleport players to the active one. No terrain streaming needed, and it’s usually the most performant option for round-based games like Deathrun.
For a Deathrun style rotation, option 3 is usually the least headache. Options 1 and 2 shine if you specifically want a single arena location that swaps content.
Thanks! Ill prob just build them in seperate locations, especially considering terrain has occlusion culling now (I think)