I’m working on some terrain generation, and I’m doing a grid based one to have way bigger worlds. So far it works, and it generates one row. But generating the next row leads to this error:
Here is the code (Area of line 33):
for cz=1,WorldSize do
local startX = ((cx*size)-size)*voxelSize
local startZ = ((cz*size)-size)*voxelSize
--Basemap--
for x=1,size do
for z=1,size do
x+= -cx+1 --(cx*size)-size-cx+1 --(cx*size)-(cx*size)-cx+1
z+=(cz*size)-size-cz+1
if x >= 300 or x <= 0 then
print("Uh oh!")
print(x)
end
local y = HeightMap[x][z]*amplitude
terrain:FillBlock(CFrame.new(startX+x-(size*cx)*voxelSize,y*voxelSize,startZ+z-(size*cz)*voxelSize),Vector3.new(voxelSize,voxelSize,voxelSize),Enum.Material.Rock)
end
run.Heartbeat:Wait()
end
Please help!