I’m currently trying to make a local Script replace all Grass to LeafyGrass on a Terrain at the current time. However, I’m kinda confused about the region3:ExpandToGrid(4) function.
I keep getting an “attempt to call a nil value” error.
I tried also with region:ExpandToGrid(4), but this does not support ExpandToGrid.
Without ExpandToGrid the Script failed , do to the Area trying to replace being “to big”.
If anyone has a solution, please don’t hesitate to notify me.
local region = game.Workspace.Terrain.MaxExtents
local function Region3int16toRegion3(region16)
return Region3.new(
Vector3.new(region16.Min.X, region16.Min.Y, region16.Min.Z),
Vector3.new(region16.Max.X, region16.Max.Y, region16.Max.Z)
)
end
local r3 = Region3int16toRegion3(region)
r3 = Region3:ExpandToGrid(4)
workspace.Terrain:ReplaceMaterial(r3, 4, Enum.Material.Grass, Enum.Material.LeafyGrass)