Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ReadVoxels "Region cannot be empty" help?

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

2 comments

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
0

I still get the "Region cannot be empty" error at line 5

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.