How can I make Terrain:FillBlock cut through water terrain?

When I use Terrain:FillBlock(), terrain water cuts through the terrain even if the water was created before I used FillBlock. I want to know if it’s possible to make the new terrain overwrite the water terrain.

This is what it looks like, even though it should be filling under the water:

local function createTerrain(height, x, z, material)
	local cframe = CFrame.new(Vector3.new((x * 4) - (mapWidth * 4) / 2, height * heightScale, (z * 4) - (mapWidth * 4) / 2))
	local size = Vector3.new(4, 12, 4)
	
	workspace.Terrain:FillBlock(cframe, size, material)
end

What solutions have you tried so far?
I have tried filling the same space with air (which doesn’t ignore water) before I fill again with the terrain material, and it looks like this:

local function createTerrain(height, x, z, material)
	local cframe = CFrame.new(Vector3.new((x * 4) - (mapWidth * 4) / 2, height * heightScale, (z * 4) - (mapWidth * 4) / 2))
	local size = Vector3.new(4, 12, 4)
	
	workspace.Terrain:FillBlock(cframe, size, Enum.Material.Air)
	workspace.Terrain:FillBlock(cframe, size, material)
end

I could continue doing that, but that requires all of my terrain to be filled twice (once with air, then again with another material). I have noticed that it loads slower if I do that, so I would rather just fill once. The only difference in my code is filling with air first, then another material. Does that mean that when filling with a non-air material, it ignores water? It doesn’t say that on the documentation, so I’m a little confused. Also, I am filling the water before I fill any terrain, not after.

2 Likes

I would still like to know how to do this as I am making a terrain generator that has water in it. And I want to generate perlin worm holes as caves and I want to ignore the water when digging.