I’m trying to make a building system on terrain. My issue is that terrain grass sticks out above the parts. Is there a way to change the material under the part to be something like leafy grass or dirt in game when placed?
I don’t think it’s possible to know when the part touch the terrain material, you can instead remove the grass directly after you place the part, so that depend on your placing script, when you place the part just remove the grass under it like this:
local function removeGrassUnderPart(p,padding)
yC = 0
local s = p.Size+Vector3.new(padding,0,padding)
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 Part = game.Workspace.Part -- the part you wanna remove the grass under it.
removeGrassUnderPart(Part,2) --you can chnage the padding to any number you want or make it 0 if you dont need space between your part and the grass.
2 Likes