ReplaceMaterial not working when trying to replace Grass with LeafyGrass

Hi! I’m trying to use ReplaceMaterial to change terrain from Grass to LeafyGrass inside a specific region defined by a Part. However, nothing changes when I run the code. I’ve double-checked that the terrain in that region is actually Grass, and the script is running on the server.

local part = workspace:WaitForChild("SizePart")

-- Define the region based on the Part's position and size
local min = part.Position - (0.5 * part.Size)
local max = part.Position + (0.5 * part.Size)
local region = Region3.new(min, max):ExpandToGrid(4)

-- Try to replace Grass with LeafyGrass
workspace.Terrain:ReplaceMaterial(region, 4, Enum.Material.Grass, Enum.Material.LeafyGrass)

The cylindrical part is the SizePart.

This is happening to me too; weirdly enough, it seems to work when you dont expandtogrid despite throwing errors. This may be a bug on roblox’s part :man_shrugging:
Also sorry for bump

sorry for being late but this could be due to using region3. i havent coded in a while but region3 is deprecated and the documentation says that you shouldnt use it for new work. i guess region3 may’ve finally broke now.

try using GetPartsBoundsInBox instead which is not only easier to use but won’t break.