I've recently been wanting to create maps using terrain that I can save, remove, and then load later, but it isn't working out for me so far. No errors occur, but no terrain appears. The wiki offers no tutorials that don't use workspace.Terrain.Max/MinExtents
so it's hard to understand why this isn't working.
Here's my code:
local region = workspace.Terrain:CopyRegion(Region3int16.new(Vector3int16.new(-103, 0.5, 13.2), Vector3int16.new(-27.4, 42.4, 87.6))) workspace.Terrain:Clear() workspace.Terrain:PasteRegion(region, Vector3int16.new(-103, 0.5, 13.2), false)
For anyone who is having the same problem, you must round your positions to Roblox's voxel size.
Here's what I got right after I pulled the positionToWorldVoxel
right out of the Roblox Studio Terrain Tools
local ceil = math.ceil local resolution = 4 local function positionWorldToVoxel(pos) return Vector3int16.new(ceil(pos.x / resolution), ceil(pos.y / resolution), ceil(pos.z / resolution)) end local region = workspace.Terrain:CopyRegion(Region3int16.new( positionWorldToVoxel(Vector3.new(-103, 0.5, 13.2)), positionWorldToVoxel(Vector3.new(-27.4, 42.4, 87.6)) ) ) workspace.Terrain:Clear() wait(1) workspace.Terrain:PasteRegion(region, positionWorldToVoxel(Vector3.new(-103, 0.5, 13.2)), false)