Hi,
I’m sure that I must be doing something wrong but I can’t figure this out - when I copy a region and then paste it again, its
- Copied the incorrect region
- Pasted it in the wrong location? (Not sure if this is because of 1. or not)
Video of the problem:
My Code:
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 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, minY, minZ), Vector3int16.new(maxX, maxY, maxZ))
print("Point0", point0)
print("Point1", point1)
print("Region", region)
local terrain = game.Workspace.Terrain:CopyRegion(region)
wait(10)
game.Workspace.Terrain:Clear()
wait(3)
game.Workspace.Terrain:PasteRegion(terrain, Vector3int16.new(minX, minY, minZ), true)
The 2 green blocks visualise the corners of the Region3int16, and the lower one is where it is pasted.