I’m getting an error in this script on line 19. Can someone help me?
– Variables
local mowerPart = game.Workspace.Lawnmower.Body.Model.mowerPart.Part
local GRASS_MATERIAL = Enum.Material.Grass
local LEAFY_GRASS_MATERIAL = Enum.Material.LeafyGrass
local MIN = Vector3.new(-20, -20, -20)
local MAX = Vector3.new(20, 20, 20)
– Function to replace grass terrain with leafy grass
local function replaceGrassWithLeafyGrass()
workspace.Terrain:ReplaceMaterial(Region3.new(MIN, MAX), 4, Enum.Material.Grass, LEAFY_GRASS_MATERIAL)
end
– Main loop
while true do
local cellPosition = workspace.Terrain:WorldToCell(Vector3.new(mowerPart.Position.X, mowerPart.Position.Y, mowerPart.Position.Z))
local cellMaterialColor = workspace.Terrain:GetMaterialColor(cellPosition.X, cellPosition.Y, cellPosition.Z)
-- Convert grass terrain to leafy grass
if cellMaterialColor == GRASS_MATERIAL then
replaceGrassWithLeafyGrass()
end
wait(0.1)
end