Unable to cast double to token error

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

It wont work because you need to put a Enum.Material in workspace.Terrain:GetMaterialColor( Material here ).
For example if you wanted to get the color of grass you would use this.

local cellMaterialColor = workspace.Terrain:GetMaterialColor(Enum.Material.Grass)
print(cellMaterialColor)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.