How does this perlin noise generator work?

Hello, i have recently created a Perlin Noise Generator and I want to know how math.noise() works.
Basically, the code below creates this:

local X = 75
local Z = 75
local grid = {}

for x = 1, X do
grid[x] = {}

for z = 1, Z do
	grid[x][z] = math.noise(x/20, z/20) * 100 -- How does this work?
end

end

for x = 1, X do
for z = 1, Z do
local yPos = grid[x][z]

	local part = Instance.new("Part")
	part.Anchored = true

	if yPos < -3 then
		part.Material = Enum.Material.Sand
		part.BrickColor = BrickColor.new("Cool yellow")
	else
		part.Material = Enum.Material.Grass
		part.BrickColor = BrickColor.new("Bright green")
	end
	part.Position = Vector3.new(x*5, yPos, z*5)
	part.Size = Vector3.new(5, 30, 5)
	part.Parent = workspace
end

end

local water = Instance.new(“Part”)
water.Anchored = true
water.Size = Vector3.new(X5, 30, Z5)
water.Position = Vector3.new(((X+1)*5)/2, -5, ((Z+1)*5)/2)
water.CanCollide = false
water.Transparency = .5
water.BrickColor = BrickColor.new(“Electric blue”)
water.Parent = workspace

If you know how perlin noise works, please reply.

Ive played around with perlin noise a while back but if you wanna know how math.noise() works make sure to check out the following link:
https://developer.roblox.com/en-us/api-reference/lua-docs/math

Basically what it means is math.noise generates numbers between -.5 and .5, not randomly, but using a procedural algorithm. it is super useful.

1 Like

Facinating, thank you! I have been wondering this for some time now.