A script I made which I found useful for myself so I decided to share it.
So recently, Roblox introduced the new grass feature which can be turned on through the “Decoration” property in the Terrain object.
The grass looks great, but since most developers didn’t build their map with the new grass in mind, I decided to create a script that removes the blades of grass that clip through the parts around your map.
Not sure if Roblox will end up integrating a feature for this directly, but for now, I have made this script as a workaround.
Here’s a before and after using the script:
As you can see, the grass is going through the parts.
This is after using the script, and as you can see the parts don’t have any grass going through them anymore.
How it works:
Basically, the script changes the terrain material under the parts from “Grass” to “LeafyGrass” (using Region3) which removes the grass from that area.
Heres the script:
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.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)
You can just paste this script into the console while in edit mode on Studio and run it to let it do its thing.
There might be a more efficient way to do this which I’m not aware of, but this works fine if you give it some time to run.