Hi all, I'm trying to read the material of terrain in a region that follows a player's vehicle, and I have a few small parts to set region boundaries to keep the script simple but no matter whether I have the parts or not the script always returns the error "Region cannot be empty" Any help?
while wait(2) do local region = Region3.new(Vector3.new(script.Parent.Region1.Position), Vector3.new(script.Parent.Region2.Position)) region = region:ExpandToGrid(4) local material, occupancy = game.Workspace.Terrain:ReadVoxels(region, 4) local size = material.Size for x = 1, size.X do for y = 1, size.Y do for z = 1, size.Z do print("Material at (", x, y, z, "): ", material[x][y][z]) print("Occupancy at (", x, y, z, "): ", occupancy[x][y][z]) print(script.Parent:GetBoundingBox().p) end end end end
you have probably already figured it out, but just in case, with Region3.new(), you first have to type the smaller values and then the higher ones. For example:
local reg = Region3.new(Vector3.new(-50,0,-50), Vector3.new(50,30,50))