Need Help With Terrain #1

Hello there!

I am trying to make a terrain which will randomly generated using math.noise. The code goes very well but I still have some issues/problems like always, and I guess people in this forum can help bc they are a good programmer compared to me :+1:. So I think maybe you guys can help me on something that I want to achieve in making terrain : )

Ok here is something that I want to achieve:

1) Color base on how high the terrain got generated
Like this
image

2) Smooth generated terrain in the terrain corner
I want it from this

to sopmethin like this:
image

Code
local RunService = game:GetService("RunService")

local partContainer = workspace.FogScreen

local size = 100
local resolution = 100
local frequency = math.random(2,5)
local amplitude = 10

local Terrain = {}

function Terrain.Generate()
	for x = 0,size do
		for z=0,size do
			local part = Instance.new("Part")
			part.Name = "GeneratedPart"
			part.Anchored = true
			part.TopSurface = Enum.SurfaceType.Smooth
			part.BottomSurface = Enum.SurfaceType.Smooth
			part.Size = Vector3.new(1,1,1)
			part.Parent = partContainer
			
			local height = Terrain.GetHeight(x,z)
			part.Position = Vector3.new(x,height*amplitude,z)
			part.Color = Color3.new(height,height,height)
		end
		
		RunService.Heartbeat:Wait()
	end
end

function Terrain.GetHeight(x,z)
	local noiseHeight = math.noise(x / resolution * frequency,z / resolution * frequency)
	noiseHeight = math.clamp(noiseHeight,-0.5,0.5) + 0.5
	return noiseHeight
end

return Terrain

Cheers,
The_UncleDev

1 Like

if height > 10 then
part.Color = Color3.fromRgb(0, 255, 0)
else
part.Color = Color3.fromRgb(0, 0, 255)
end

1 Like