How do I load terrain?

I want to load terrain from code. I want to do this because a want to have multiple maps and not be limited by parts.

I don’t know how I can achieve this.

I have tried to copy over the terrain part in the workspace and make multiple for each map. It seems like this would be the answer but Roblox won’t let you do that.

2 Likes

This article should help you https://developer.roblox.com/en-us/articles/Scripting-With-Terrain. You can use Terrain:ReadVoxels and Terrain:WriteVoxels to save and write terrain in table form. An easier approach might be to use Terrain:FillBlock to fill in a part with terrain.

2 Likes

Check out Crazyman32’s Load & Save Terrain Plugin. I’ve that successfully in the past.
Create your Terrain, then export it using the Plugin and place into Server Storage. You can then load and unload using the following:

workspace.Terrain:Clear()    -- Clears the existing Terrain
workspace.Terrain:PasteRegion(terrainSource, workspace.Terrain.MaxExtents.Min, true)   -- Loads the Terrain in from the location specified in the ```terrainSource``` variable.
7 Likes

Thanks I’ll have to give that a read.

I’ll check out the plugin. Thanks!