Procedural noise Generation not so Procedural

Hello! I’ve made a “Procedural Generation” which isn’t so “Procedural” I’m not sure what I’m doing wrong though this is my code in server script service:

local X = 250 --How long the map is
local Z = 250 --How wide the map is
local Seed = math.random(10, 45) --The base height for the map
local waterHeight = math.random(-5, 0) --How high the water level is
local extraSand = math.random(2, 3) -- How much extra sand before water level
local randomNum = math.random(10, 25) --First number in the generation phase
local mountainHeight = math.random(25, 35) --This decides the height of when the mountain becomes stone
-----------------------------------------------------------DON'T TOUCH ANYTHING BELOW THIS POINT!!!
local randomNumTwoStart = randomNum+2
local randomNumTwoEnd = randomNum-2

local randomNumTwo = math.random(randomNumTwoEnd, randomNumTwoStart) --Second number in the generation phase

local totalSeed = X*Z*Seed*waterHeight*extraSand*randomNum*randomNumTwo*mountainHeight

print("Seed = "..totalSeed)
print("Random Numbers "..randomNum, randomNumTwo)
print("Water Height = "..waterHeight)
print("Extra Sand = "..extraSand)
print("Base Height = "..Seed)
local grid = {}

local partsFolder = Instance.new("Folder")
partsFolder.Parent = game.Workspace
partsFolder.Name = "PartsFolder"

local grassFolder = Instance.new("Folder")
grassFolder.Parent = partsFolder
grassFolder.Name = "GrassFolder"

local sandFolder = Instance.new("Folder")
sandFolder.Parent = partsFolder
sandFolder.Name = "SandFolder"

local rockFolder = Instance.new("Folder")
rockFolder.Parent = partsFolder
rockFolder.Name = "RockFolder"

for x = 1, X do
	grid[x] = {}
	
	for z = 1, Z do
		grid[x][z] = math.noise(x/randomNum, z/randomNumTwo) * Seed/0.45 or 0.5 or 0.55 or 0.6
	end
end

for x = 1, X do
	for z = 1, Z do
		local yPos = grid[x][z] * waterHeight
			local part = Instance.new("Part")
			part.Anchored = true
			part.Material = Enum.Material.SmoothPlastic
			if yPos < waterHeight + extraSand then
				part.BrickColor = BrickColor.new("Cool yellow")
				part.Parent = sandFolder
				part.Name = "Sand"
			else
				if yPos > mountainHeight then
					part.BrickColor = BrickColor.new("Medium stone grey")
					part.Parent = rockFolder
					part.Name = "Stone"
				else
					part.BrickColor = BrickColor.new("Shamrock")
					part.Parent = grassFolder
					part.Name = "Grass"
				end
			end
			local yPos = grid[x][z]
		local part = Instance.new("Part")
		part.Anchored = true
		part.Material = Enum.Material.SmoothPlastic
		if yPos < waterHeight + extraSand then
			part.BrickColor = BrickColor.new("Cool yellow")
			part.Parent = sandFolder
			part.Name = "Sand"
		else
			if yPos > mountainHeight then
			part.BrickColor = BrickColor.new("Medium stone grey")
			part.Parent = rockFolder
				part.Name = "Stone"
				else
				part.BrickColor = BrickColor.new("Shamrock")
				part.Parent = grassFolder
				part.Name = "Grass"
		end
		end
		
		part.Position = Vector3.new(x*5, yPos, z*5)
		part.Size = Vector3.new(5, 180, 5)
		end
		end

local water = Instance.new("Part")
water.Anchored = true
water.Size = Vector3.new(X*5, 180.01, Z*5)
water.Position = Vector3.new(((X+1)*5)/2, waterHeight, ((Z+1)*5)/2)
water.CanCollide = false
water.Transparency = 0.5
water.BrickColor = BrickColor.new("Electric blue")
water.Material = Enum.Material.SmoothPlastic
water.Reflectance = 0.1
water.Parent = game.Workspace
water.Name = "Water"

local Spawn = Instance.new("SpawnLocation")
Spawn.Anchored = true
Spawn.Size = Vector3.new(3, 1, 3)
Spawn.Position = Vector3.new(((X+1)*5)/2, Seed+10, ((Z+1)*5)/2)
Spawn.CanCollide = false
Spawn.Transparency = 1
Spawn.Parent = game.Workspace
Spawn.Name = "SpawnPoint"

waterB = Instance.new("Part")
waterB.Anchored = true
waterB.Size = Vector3.new(X*5, 180.01, Z*5)
waterB.Position = Vector3.new(((X+1)*5)/2, waterHeight-4, ((Z+1)*5)/2)
waterB.Transparency = 1
waterB.BrickColor = BrickColor.new("Electric blue")
waterB.Material = Enum.Material.SmoothPlastic
waterB.Parent = game.Workspace
waterB.Name = "WaterBottom"

And please to those who want to use this script don’t just copy it please read it and see what it does and how it does it first, Thank you! Any help is appreciated…

Ummm… Can I have some help? Please…

Hi there. Can you please format your code so it’s more readable? See this post on how to do that. It would also be helpful to get more info on what’s going wrong and what exactly you want help with. When you say it isn’t procedural as you expected it, what do you mean? What’s the desired output?

2 Likes

Put three backticks around your code
```
like this
```
so it shows up

like this

Also please answer all of these questions:

  1. What do you want to achieve? Keep it simple and clear!
  2. What is the issue? Include screenshots / videos if possible!
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub ?

Thanks for showing me how to do that. But what could I do to generate randomly

While trying to run your code, it often freezes Studio for a few seconds. This also does mean that the server in production will also freeze for a few seconds, impacting user experience. Consider adding delays in your script, like in this solution to a problem.

You forgot to answer these questions, nobody can help until you do!

1 Like

What exactly isn’t procedural?