When running this code, It only works occasionally. And I think its got something to do with the position of the terrain I’m trying to get the Region3Int16.
If its Centre is close to (0,0,0) then it works, if not then it doesn’t
When it doesn’t work the terrain is never pasted but TerrainRegion is not nil so I don’t know
I might be wrong but can someone please explain it to me and take a look at this?
PartRegions = game.Workspace.PartRegions:GetChildren()
for i = 1,#PartRegions do
local min = PartRegions[i].Position - (0.5 * PartRegions[i].Size)
local max = PartRegions[i].Position + (0.5 * PartRegions[i].Size)
local region = Region3int16.new(Vector3int16.new(min.X,min.Y,min.Z), Vector3int16.new(max.X,max.Y,max.Z))
local terrainRegion = workspace.Terrain:CopyRegion(region)
workspace.Terrain:FillBlock(PartRegions[i].CFrame,PartRegions[i].Size,Enum.Material.Air)
wait(3)
workspace.Terrain:PasteRegion(terrainRegion, region.Min, true)
end