I need help with my terrain generator

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

The terrain generator I scripted works, but I want to prevent these holes from appearing, and these weird lines. I would appreciate any help.

  1. What is the issue? Include screenshots / videos if possible!
    I tried breaking the loop to prevent these massive holes from happening when you stop generating the terrain, but instead, it made the problem worse.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried using an if statement to break the loop, but it made the problem worse.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

function generate()
local positions = {}
	local ypos

	local totalx
	local totalz
	local zoom = 75
	local height = 100
	local size = 2048
	for x = -30,size do
		for z = -30,size do
			
			local pos = CFrame.new(x,math.noise(x/zoom,z/zoom)*height+25,z)
			ypos = pos.Y
			table.insert(positions,pos)
			local size = Vector3.new(1,1,1)
			if (pos.Y>math.random(60,80)) then
				workspace.Terrain:FillBlock(pos,size,Enum.Material.Rock)
			elseif (pos.Y<math.random(1,5)) then
				workspace.Terrain:FillBlock(pos,size,Enum.Material.LeafyGrass)
			else
				workspace.Terrain:FillBlock(pos,size,Enum.Material.Grass)

			end
			if(z>=1000-260 and pos.Y<2) then
				totalz = z
				break
			end
		end
		if(x>=1000 and ypos<2) then
			totalx = x
			break
		end
	end
	print(totalx,totalz)
	
	workspace.Terrain:FillBlock(CFrame.new(totalx/2,30,totalz/2),Vector3.new(totalx*2,10,totalz*2),Enum.Material.Grass)
	workspace.Terrain:FillBlock(CFrame.new(totalx/2,-2,totalz/2),Vector3.new(totalx*5,1,totalz*5),Enum.Material.Sand)
	workspace.Terrain:FillBlock(CFrame.new(totalx/2,5,totalz/2),Vector3.new(totalx*5,5,totalz*5),Enum.Material.Water)
end

generate()

Any help is appreciated :slight_smile:

I need help a bit more urgently now.

But I’m not going to get into it very much Because I dont know it. But I would generate parts and fill them with terrain. (because I can fill the terrain based on the part, and I’ve seen a manual for generating random parts.)

1 Like

That would end up as the same exact result when you think about it, wouldn’t it?

Well I dont know. I recently worked on restoring the terrain when the player is far away, and I have in those places where it’s supposed to create invisible parts.

for testing, replace the terrain with parts. - will do the same (probably), but you will be better off seeing how it does. And better then try to improve it.