So, here's my problem. I am in the process of making a mining game and the system I am using works just fine but I am having a little trouble creating the blocks. Whenever a block is being mined, the server creates blocks around the one being mined. Now, the way I find out what blocks to make where, I put all the surrounding Vector3 Values in a table and then compare them to another table containing all the blocks:
local pp=part.Position
local sides={}
sides[1]=pp+Vector3.new(2,2,2)
sides[2]=pp+Vector3.new(0,2,2)
sides[3]=pp+Vector3.new(-2,2,2)
sides[4]=pp+Vector3.new(2,2,0)
sides[5]=pp+Vector3.new(0,2,0)
sides[6]=pp+Vector3.new(-2,2,0)
sides[7]=pp+Vector3.new(2,2,-2)
sides[8]=pp+Vector3.new(0,2,-2)
sides[9]=pp+Vector3.new(-2,2,-2)
sides[10]=pp+Vector3.new(2,0,2)
sides[11]=pp+Vector3.new(0,0,2)
sides[12]=pp+Vector3.new(-2,0,2)
sides[13]=pp+Vector3.new(2,0,0)
sides[14]=pp+Vector3.new(0,0,0)
sides[15]=pp+Vector3.new(-2,0,0)
sides[16]=pp+Vector3.new(2,0,-2)
sides[17]=pp+Vector3.new(0,0,-2)
sides[18]=pp+Vector3.new(-2,0,-2)
sides[19]=pp+Vector3.new(2,-2,2)
sides[20]=pp+Vector3.new(0,-2,2)
sides[21]=pp+Vector3.new(-2,-2,2)
sides[22]=pp+Vector3.new(2,-2,0)
sides[23]=pp+Vector3.new(0,-2,0)
sides[24]=pp+Vector3.new(-2,-2,0)
sides[25]=pp+Vector3.new(2,-2,-2)
sides[26]=pp+Vector3.new(0,-2,-2)
sides[27]=pp+Vector3.new(-2,-2,-2)
This is the way I figure out where to check for blocks to place (note: each block is 2x2x2). The way I typed it up is very time consuming and gives me a headache trying to keep track of the values to make sure I don't mess up or forget one. Is there a better way of doing this with a loop and can it be extended for more layers of blocks?

3 comments
Thank you so much! I have been wondering an easier way to do this but I didn't quite know how or where to start. Is there a way to figure out not only the blocks just outside the first but the ones after that as well? For example: 2-1-0-1-2 (not just around the first layer but also a second layer)
Wait a sec, would it be just as easy as for x=-2,2 do ?
Yes, yes it was XD