# How do I use perlin noise?

I want to create a baseplate using Perlin noise and parts and I’m wondering how I can do that because there are not that many tutorials out there for Roblox Perlin noise.

I want to generate something like this:

if you could help that would be good!

10 Likes

I have used perlin noise before for something similiar. I can go in studio in some of those old projects and grab some code if you have more questions, but here are some discussions I found on the forums that should help you out:

4 Likes

Can you go in studio for the old projects?

1 Like

This one is a very simple explanation of using perlin noise for generation:

7 Likes

that video wont load for meeee

2 Likes

Did you read this post:

2 Likes

Yes but thats not the type of map im looking for

1 Like

What do you want different in your generation?

I want to make it a hilly terrain I found something like it ages ago that was what I wanted it came with a city and forest thing by roblox staff or something

1 Like

You may want to play around with perlin noise and look more into it. Also, I recommend making multiple octaves of noise and layering them on top of each other as I personally think it looks better. I have not touched it in a few years but I just made something real quick that works. “Amp” is the variable that is the multiplier of the height that you get. Size_x and z are the amount of blocks in the x and z direction that are to be generated. You can also play around with what numbers they are divided by as well if you want. This also makes blocks on top of each other, which is not all that efficient but I did it just for demonstration. Here is the code and some screenshots:

``````math.randomseed(os.time())

local block = game:GetService("ServerStorage"):WaitForChild("Block")

local size_x = 64
local size_z = 64
local seed = math.random(1, 10^8)

local amp = 56

local function draw(x, y, z)
local new = block:Clone()
new.CFrame = CFrame.new(x, y, z)
new.Parent = workspace
end

for x = 0, size_x*block.Size.X, block.Size.X do
wait()
for z = 0, size_z*block.Size.Z, block.Size.Z do

draw(x, 0, z)

local height = math.noise(x/280.5, z/292.7, seed)*amp

height = math.floor(height)

for i = 0, height*block.Size.Y, block.Size.Y do
draw(x, i, z)
end
end
end
``````

4 Likes

I tried making my own but it is not working

``````local PositionX, PositionY, PositionZ = 100, 10, 100
local NoiseScale = 50
local Amplitude = 25
math.randomseed(tick())
local MathRandom = math.random()
local Size = 5

for Number = 1, PositionX do
for Number2 = 1, PositionY do
for Number3 = 1, PositionZ do
local MathNoiseX = math.noise(Number2 / NoiseScale, Number3 / NoiseScale, MathRandom) * Amplitude
local MathNoiseY = math.noise(Number / NoiseScale, Number3 / NoiseScale, MathRandom) * Amplitude
local MathNoiseZ = math.noise(Number / NoiseScale, Number2 / NoiseScale, MathRandom) * Amplitude
local Density = MathNoiseX + MathNoiseY + MathNoiseZ
if Density < 20 and Density > 15 then
local Part = Instance.new("Part")
Part.Position = Vector3.new(Number * Size, Number2 * Size, Number3 * Size)
Part.Anchored = true
Part.Parent = workspace
end
end
end
end
``````
1 Like

“Size” is undefined:

Also, you could try mine out. It works, you just may want to change to position changing later on instead of making new blocks on top

Its not making a hill terrain that I want

1 Like

Depending on the seed, the terrain will always be different. Just play around with the variables and see what you like.

this is the problem

1 Like

Put a part in ServerStorage named “Block” that is 4 size in each direction (x, y, z). Also show the code you are using.

I am currently experimenting with perlin noise and terrain generation.

With perlin noise, you give it a set of coordinates and a seed which gives you a random value somewhere around -1 and 1, but not exactily.

With that number, you can use it to determine whether you need to place terrain there, and what color.

2 Likes

Yes that is correct

1 Like