Erode Terrain With Script

Hello everyone!

Does Roblox have any feature to erode terrain with a script? I know Roblox has a fillblock feature where you can create terrain with a script. I’m not sure sure how to erode certain amounts of terrain using a script.
So far there isn’t any answer in the Devforum/hub, but just wanted to know if such a system really exists.

For example, someone is going to place a house on a plot of land. But the plot of land is really bumpy and uneven, and if the user were to place the house on the plot, some terrain would go into the house. I would need a way to erode the excess terrain using a script. This is what I’m talking about: (EXAGGERATED)


This is what I used to create my terrain (I didn’t use a script, but the Terrain Editor):

Can anyone help me solve this, please?

Thanks!
(If this goes into Game Design Support instead, please tell me.)

2 Likes

I believe you can flatten the terrain using a Region 3 and the terrain class’s FillRegion function using air as the material, or you can also use the FillBlock function as well with air still as the material

1 Like

DISREGARD THIS REPLY; IT’S SOLVED BUT IF I DELETE IT OTHER MESSAGES MAY BE EFFECTED

Hmm… somehow I still can’t erode the terrain. The Region3 and the FillBlock function still only generates terrain, and doesn’t erode it. (The terrain I’m trying to erode was made by using the Terrain Editor, I didn’t use a script, to clarify.)
I also tried using the ReplaceMaterial function but then I couldn’t place it where I wanted to, and it also didn’t replace some terrain parts.
Here’s an example of what I was talking about in the example: (I would need the bumps circled in red eroded away with a script)


This is what I used to create my terrain: (the Terrain Editor)

I don’t have too much knowledge with terrain, but so far this is what I know with the FillRegion and Region3 functions… is there still any way (or another) to get the terrain to flatten?
Thanks!

FillRegion is what you want. Fill the location with Enum.Material.Air

Terrain:FillRegion (roblox.com)

1 Like

@meriadocb Oops! My bad, using FillRegion/Region3 does work, I just did it in the wrong way.

@MrNicNac Is there any way to specify where the FillRegion fills a location? Right now, it seems that the FillRegion is aligned to the center of the grid. I think the Developer Hub says that I can position it with CFrame, but I’m not sure how? (There’s an error when I try something like "region.CFrame = CFrame.new(…))
For example, in the picture below, the terrain circled in blue. is what is being eroded/filled with air. But how would I make the terrain circled in red filled with air and not the one in blue?

If you can get the bounding box of the house, you can use FillBlock with the bounding box. If the box is a part, you would do something like this:

Terrain:FillBlock(Part.CFrame, Part.Size, Enum.Material.Air)
1 Like

@meriadocb @MrNicNac @Styre_x
Oh, my! You were all actually right, I was just using the functions in the wrong way.
I thought the FillRegion function would only generate terrain, but it could also ‘erode’ terrain too. Same for the FillBlock function; I thought the fillblock function would only turn a part into air, but if the part touches another piece of terrain, that terrain would also be affected.
Sorry for the inconvenience, but thank you all for teaching me how; have a lovely day! :heart:

1 Like