I keep running into this annoying error
12:11:41.501 - Bad argument materials[1][1] to ‘WriteVoxels’ (2-element 12:11:41.501 - Script ‘ServerScriptService.Script’, Line 53 - global WriteVoxelsarray expected)
So I’ve tried just, making these generate an array with only 2 “dimensions” and that gave me a slightly different error
12:14:22.108 - Bad argument materials[1][1] to ‘WriteVoxels’ (1-element array expected)
This doesn’t really seem to work how the wiki made it out to work. And I can’t really find any better documentation on how this works. can anyone help?
function GenerateOccupancy(h)
local A = {}
A[1] = {}
local hRound = math.ceil(h/4)
local hRemainder = 1%(h/4)
for i = 1,hRound do
A[1][i] = {}
if i == hRound then
A[1][i][1] = hRemainder
else
A[1][i][1] = 1
end
end
return A
end
function GenerateMaterial(h,material)
local A = {}
A[1] = {}
local hRound = math.ceil(h/4)
local hRemainder = 1%(h/4)
for i = 1,hRound do
A[1][i] = {}
if i == hRound then
A[1][i][1] = Enum.Material.Grass
else
A[1][i][1] = Enum.Material.Rock
end
end
return A
end
function WriteVoxels(x,y,height,material)
print(Unit)
local Region = Region3.new(Vector3.new(x,0,y),Vector3.new(x + Unit,height,y + Unit))
Region = Region:ExpandToGrid(4)
game.Workspace.Terrain:WriteVoxels(Region,4,GenerateMaterial(height,material),GenerateOccupancy(height))
end
