How can I make my terrain more smooth using scripts?

I ahve a terrain generator but it generates it raggedly like blocks instead of smooth

e.g

Does anyone know how I can smooth it out using code

1 Like

You can always use the part to terrain plugin where you can add parts where you want the terrain smooth and add over it to make it that way. (I don’t have a link so just look it up it shouldn’t be to hard to find)

“I ahve a terrain generator”…

1 Like

well that was a suggestion to using parts and a plugin to smooth it out manually. Scripting it would take much longer and this isn’t a terrain generator is doesn’t just make it, it is done manually via parts.

You cannot smooth terrain using scripts , however you could try using the Terrain:FillBlock(the part's cframe, the part's size, Enum.Material.Yourmaterialtochoose)

If you’re setting the occupancy of the terrain at each coordinate to discrete values, like 0 and 1, then that might explain the jaggedness. Try an approach that sets it to a value between 0-1 that’s smoothly generated

local WorldProportionX, WorldProportionZ = 100, 100
local NoiseScale = 50
local Height = 5
local PartProportion = 50
math.randomseed(tick())
local MathRandom = math.random()

for Number = -WorldProportionX, WorldProportionX do
	for Number2 = -WorldProportionZ, WorldProportionZ do
		local MathNoise = math.noise(Number / NoiseScale, Number2 / NoiseScale, MathRandom) * Height
		local Part = Instance.new("Part")
		Part.Anchored = true
		Part.CFrame = CFrame.new(Number * PartProportion, MathNoise * PartProportion, Number2 * PartProportion)
		Part.Size = Vector3.new(PartProportion, PartProportion, PartProportion)
		Part.Parent = workspace.Terrain
		workspace.Terrain:FillBlock(Part.CFrame, Part.Size, Enum.Material.Grass)
	end
	wait()
end

Terrain Generator!

I don’t understand what you could you by any chance provide an example?

I was looking at the bottom of the doc: Terrain Editor | Documentation - Roblox Creator Hub

Since that implementation uses :FillBlock(), it can only set each voxel to completely occupied or not at all. If you instead use WriteVoxels(), you can set the occupancy to anything between 0 and 1, letting you get smoother terrain.

I think… :sweat_smile:

1 Like

I dont get how to use writevoxels every value I change gives an error