A way to clear all terrain except one region?

*What do you want to achieve?
So far I’ve learned to copy and paste regions for my game that uses them for certain maps. My lobby currently has Terrain in it and would be affected heavily if I just used Terrain:Clear() for whenever I wanted to change maps.

What solutions have you tried so far?
So far I’ve tried setting the current region of the map to air using FillTerrain:() but that doesn’t work since it doesn’t work with Region3int16. It only takes Region3 for some reason.

Here’s the script that errors with Region3int16. If I switch it all to Region3, you can’t use :CopyRegion() and if I switch it all to Region3 you can’t use FillRegion().

local post0, post1 = game.Workspace.post0, game.Workspace.post1

local point0 = post0.Position + Vector3.new(0, post0.Size.Y/2, 0)
local point1 = post1.Position - Vector3.new(0, post1.Size.Y/2, 0)

local r = 4
local minX = math.min(point0.X, point1.X)
local maxX = math.max(point0.X, point1.X)
local minY = math.min(point0.Y, point1.Y)
local maxY = math.max(point0.Y, point1.Y)
local minZ = math.min(point0.Z, point1.Z)
local maxZ = math.max(point0.Z, point1.Z)



local corner = Instance.new("Part")
	corner.Anchored = true
	corner.Size = Vector3.new(1.2, 1.2, 1.2)
	corner.Position = Vector3.new(minX, minY, minZ)
	corner.Color = Color3.fromRGB(0,255,0)
local corner2 = corner:Clone()
	corner2.Position = Vector3.new(maxX, maxY, maxZ)
	
corner.Parent = game.Workspace 
corner2.Parent = game.Workspace



local region = Region3int16.new(Vector3int16.new(minX/r, minY/r, minZ/r), Vector3int16.new(maxX/r, maxY/r, maxZ/r))
print("Point0", point0)
print("Point1", point1)
print("Region", region)



local terrain = game.Workspace.Terrain:CopyRegion(region)
wait(10)
local SmoothTerrainAirCode = 1792;
local Resolution = 1;
workspace.Terrain:FillRegion(region, Resolution, SmoothTerrainAirCode);

You can convert the Region3int16 into a Region3, then try using FillTerrain()

local function Region3int16toRegion3(region16)
	return Region3.new(
		Vector3.new(region16.Min.X, region16.Min.Y, region16.Min.Z),
		Vector3.new(region16.Max.X, region16.Max.Y, region16.Max.Z)
	)
end

My newest idea is to clear the area I don’t need. As clearing all area except one region would never work unless Roblox designed something specifically for that.

Anyways here’s the messy code I have now:

local post0, post1 = game.Workspace.post0, game.Workspace.post1

local point0 = post0.Position + Vector3.new(0, post0.Size.Y/2, 0)
local point1 = post1.Position - Vector3.new(0, post1.Size.Y/2, 0)

local r = 4
local minX = math.min(point0.X, point1.X)
local maxX = math.max(point0.X, point1.X)
local minY = math.min(point0.Y, point1.Y)
local maxY = math.max(point0.Y, point1.Y)
local minZ = math.min(point0.Z, point1.Z)
local maxZ = math.max(point0.Z, point1.Z)



local corner = Instance.new("Part")
	corner.Anchored = true
	corner.Size = Vector3.new(1.2, 1.2, 1.2)
	corner.Position = Vector3.new(minX, minY, minZ)
	corner.Color = Color3.fromRGB(0,255,0)
local corner2 = corner:Clone()
	corner2.Position = Vector3.new(maxX, maxY, maxZ)
	
corner.Parent = game.Workspace 
corner2.Parent = game.Workspace



local region = Region3int16.new(Vector3int16.new(minX/r, minY/r, minZ/r), Vector3int16.new(maxX/r, maxY/r, maxZ/r))
print("Point0", point0)
print("Point1", point1)
print("Region", region)

local function Region3int16toRegion3(region16)
	return Region3.new(
		Vector3.new(region16.Min.X, region16.Min.Y, region16.Min.Z),
		Vector3.new(region16.Max.X, region16.Max.Y, region16.Max.Z)
	)
end

local terrain = game.Workspace.Terrain:CopyRegion(region)
wait(1)
local SmoothTerrainAirCode = 1792;
local Resolution = 1;
workspace.Terrain:FillRegion(
	Region3int16toRegion3(region):ExpandToGrid(4), 
	4, 
	SmoothTerrainAirCode);

Sadly there are no errors and nothing happens to the region. It doesn’t change/get cleared. Any ideas how I can fix this/troubleshoot?

I know this was two days ago, but how would I turn Region3 into Region3int16?