I am making a procedural terrain generator, using 3d noise for underground enviroments. The problem is that it is too slow for larger maps and use too much script activity and rate:

I would like to know if there is a faster terrain function. I saw WriteVoxels and thought that maybe it could work but I am not sure and I don’t really understand it yet.

I also would like to know if using FillBlock() once to generate a 1x10x1 terrain is as performance friendly and as fast as using FillBlock() 10 times to generate 1x1x1.

Also would like to know some tips you might have about accelerating this process.

Things I tried:

- Worm noise instead of 3d (is a bit faster, but still lags the server while generating and isnt as fun as this one);
- Chunk system (works, but even loading closer chunks lag).

Here is the code if it might help you solving this problem for me:

```
local resolution = 150
local frequency = 10
local power = 20
local Seed = math.random(1,1000000)
local MaxDensity = -2
local MaxDensityg = -3
local scale = 8
script:ClearAllChildren()
workspace.Terrain:Clear()
for x = 0, resolution do
wait()
for y = 0, resolution do
for z = 0, resolution do
local X = math.noise((y/frequency),(z/frequency),Seed)*power
local Y = math.noise((x/frequency),(z/frequency),Seed)*power
local Z = math.noise((y/frequency),(x/frequency),Seed)*power
local Density = X + Y + Z
if y <=2 then
workspace.Terrain:FillBall(Vector3.new(x*scale,y*scale,z*scale),scale,Enum.Material.Basalt)
elseif y >= resolution-2 then
workspace.Terrain:FillBall(Vector3.new(x*scale,y*scale,z*scale),scale,Enum.Material.Grass)
elseif Density < MaxDensityg then
if y > 10 then
workspace.Terrain:FillBall(Vector3.new(x*scale,y*scale,z*scale),scale,Enum.Material.Ground)
else
workspace.Terrain:FillBall(Vector3.new(x*scale,y*scale,z*scale),scale,Enum.Material.CrackedLava)
end
elseif Density < MaxDensity then
workspace.Terrain:FillBall(Vector3.new(x*scale,y*scale,z*scale),scale,Enum.Material.Rock)
end
end
end
end
```