Hi!
I am making cave generation, but the end results makes a very bugged striped block pattern.
I’ll provide some code and stuff but I don’t really know what I am doing wrong
This generates a perfect grid of block positions:
c_z, c_y and c_z are the chunk positions for the x, y, z and dimensions.
for x = 1, WorldSettings.ChunkSize / WorldSettings.BlockSize, 1 do
for y = 1, WorldSettings.ChunkSize / WorldSettings.BlockSize, 1 do
for z = 1, WorldSettings.ChunkSize / WorldSettings.BlockSize, 1 do
local blockPos = Vector3.new(
c_x * WorldSettings.ChunkSize + x * WorldSettings.BlockSize,
c_y * WorldSettings.ChunkSize + y * WorldSettings.BlockSize,
c_z * WorldSettings.ChunkSize + z * WorldSettings.BlockSize
)
if blockPos.Y <= WorldSettings.SurfaceLevel then
table.insert(BlockPoints, {Position = blockPos})
end
end
end
end
local NewBlockPoints = Caves:GenerateCaves(BlockPoints, WorldSettings)
for _, B in pairs(NewBlockPoints) do
Blocks:PlaceBlock(ChunkModel, B.Position, WorldSettings.BlockSize)
end
And this function checks if the noise is above a certain value and removes the block points which are in the way.
function Caves:GenerateCaves(BlockPoints, WorldSettings)
local seed = WorldSettings.Seed + 1
local NewBlockPoints = BlockPoints
for i, B in pairs(NewBlockPoints) do
local x = B.Position.X
local y = B.Position.Y
local z = B.Position.Z
local x_noise = math.noise(y / WorldSettings.CaveScale, z / WorldSettings.CaveScale, seed) * WorldSettings.CaveAmp
local y_noise = math.noise(x / WorldSettings.CaveScale, z / WorldSettings.CaveScale, seed) * WorldSettings.CaveAmp
local z_noise = math.noise(x / WorldSettings.CaveScale, y / WorldSettings.CaveScale, seed) * WorldSettings.CaveAmp
local density = x_noise + y_noise + z_noise
if density > WorldSettings.CaveDensity then
table.remove(NewBlockPoints, table.find(BlockPoints, B))
end
end
return NewBlockPoints
end
The result of the noise function is very weird, and I appreciate any help I can get. Have a nice day! 
