Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ReadVoxels "Region cannot be empty" help?

Asked by 5 years ago

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
0
1. Don't call wait() in your loop's condition; it is misleading and is not explicit. 2. You don't need to create a new Vector3, the Position property is already a Vector3. So remove the Vector3.new call and just put the position User#24403 69 — 5y
0
I still get the "Region cannot be empty" error at line 5 TimberWolffe 0 — 5y

1 answer

Log in to vote
0
Answered by 4 years ago

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))

Ad

Answer this question