I am currently creating my own terrain generation script (primarily based around perlin noise, with other elements). I am continually running into an error however. Whenever I start the game, my code breaks in the GenerateMountain section.
Here is the current code, I am trying to figure out the cause of the break, and what I need to do to fix it, additionally, if you have feedback on the generation formulas on their own, I’m open to that.
local Core = {Functions = {}, Pathways = {}}
Core.__index = Core
local len = 250
local size = 2
local zoom = 50
local amp = 30
function Core.Functions.GeneratePerlinTerrain(self)
for x = -len,len do
for z = -len,len do
local y = math.noise(x/zoom,z/zoom)*amp
if y < -2.75 then
game.Workspace.Terrain:FillBlock(CFrame.new(x*size,2,z*size),Vector3.new(size,size*2,size),Enum.Material.Water)
else
game.Workspace.Terrain:FillBlock(CFrame.new(x*size,y,z*size),Vector3.new(size,size*2,size),Enum.Material.Grass)
end
end
end
end
function Core.Functions.GenerateMountain(self,X,Y,Z,Amount)
for i = 1,Amount do
game.Workspace.Terrain:FillBlock(CFrame.new(X,Y,Z),Vector3.new(Amount*Amount-(i*10),Y*(i*2),Amount*Amount-(i*10)),Enum.Material.Rock)
end
end
Core.Functions:GeneratePerlinTerrain()
for i = 1,10 do
Core.Functions:GenerateMountain(math.random(10,15),math.random(15,20),math.random(10,15),math.random(5,10))
end