Stopping grass from showing though parts

Hello, I am new to DevForum, so excuse me if I have posted this under the wrong sections.

I am working on a scary story game, and have decided to take advantage of the new grass to add a more realistic effect to the stories. But, there is an issue I have come across in all the stories I have added terrain to. That is, the grass shows and moves up through the parts I have on the ground. I have tried removing the terrain under the parts, but that is very time consuming and difficult, as the tools available are not small enough and remove the grass around the part. So the question is: Is it possible for me to decide which parts the grass is allowed to show through, or is this not a feature yet? Thanks!

Edit:
Painting just the terrain under the part prevents grass from appearing around the model the grass is coming through, as the paint tool is too large, and the model too small, to paint just directly under it.


9 Likes

Paint the area under the parts to a material that isn’t grass, like mud or something.

2 Likes
8 Likes

While this does stop grass from showing through parts, it stops it from showing through all parts. I have terrain generated under the grass style part, and using the script does not let it show through. I only want the grass to not come through the specified parts, not my whole game.

Using the paint tool to change the material of the terrain under the parts resulted in an area around the part where the material also changed, removing grass from around the part.


Also, yes I have snap to grid disabled.

Well first of all, don’t use the wood material because that obviously isn’t natural looking at all.

If you use Leafy Grass it is harder to tell that it is different and grass won’t spawn on it.

I’ve also edited the script to it doesn’t remove grass under parts with a certain name.

   local function regionPaintPart(p, yC, padding)
--each part is divided into smaller regions (each with a size of 4x4 studs) since some parts are rotated and regions cant be rotated
padding = padding or 0
local s = p.Size+Vector3.new(padding*2,0,padding*2)
for x=1, s.X/3 do
	for z=1, s.Z/3 do
		if ((z+x)%200)==0 then
			wait()
		end
		local p2c = CFrame.new(p.CFrame:PointToWorldSpace(Vector3.new(x*3,yC,z*3)-Vector3.new(s.X/2,0,s.Z/2)))
		local p2s = Vector3.new(5,5,5)
		local r = Region3.new(p2c:PointToWorldSpace(-Vector3.new(p2s.X/2,5,p2s.Z/2)), p2c:PointToWorldSpace(Vector3.new(p2s.X/2,5,p2s.Z/2)))
		workspace.Terrain:ReplaceMaterial(r:ExpandToGrid(4) ,4,Enum.Material.Grass, Enum.Material.LeafyGrass)
	end
end
end

local function FixGrassPart(p, pad)
     regionPaintPart(p, 0, pad)
end

local function FixAllGrassParts(pad)
    for _, v in pairs(workspace:GetDescendants()) do
	    if v:IsA("BasePart") and not v:IsA("MeshPart") and not v:IsA("Terrain") and v.Name == "NoGrassUnderThisPart" and v.Size.Y < 10 then
		    print(v)
		    if (_%100)==0 then
			    wait() --Waits every 100 parts so it doesn't freeze studio
		    end
		    FixGrassPart(v, pad)
	   end
end
print('FINISHED')
end

wait()

FixAllGrassParts(2)

Just change the name of the parts you want no grass under to “NoGrassUnderThisPart”, run the script, then you can change their names back.

4 Likes

Why that when he can just paint the terrain below?

1 Like

I am asking myself too, and I have no idea, lol.

According to DyoxDev, he can’t paint the terrain, it messes something else up.

1 Like

The script @BCbuds created was not effective in removing the grass under the specified parts. Instead, it removed all grass from a large radius. If someone can make this script more localized to the part, that would be amazing. Thanks!