Terrain filling bug

I’m trying to create a terrain generating system that fills blocks. I created it and it did what it was supposed to (kind of).

When I find the Mouse.Target and retreive the material, it gives me plastic. Even though I destroy the Parts that were filled.

I’ve tried destroying the parts, changing properties, changing the parent. It wont work. And it’s not the terrain that’s actual plastic, because when I go through it, it returns grass.

-- Variables

local FillableRegions = workspace:WaitForChild("FillableRegions")
local Terrain = workspace.Terrain

-- Create the correspondent tables

local RegionsWorld1 = {
	FillableRegions:WaitForChild("FillGrass"),
	FillableRegions:WaitForChild("FillMud"),
	FillableRegions:WaitForChild("FillRock"),
	FillableRegions:WaitForChild("FillCrackedLava")
}

local CorrespondentMats = {
	Enum.Material.Grass,
	Enum.Material.Mud,
	Enum.Material.Rock,
	Enum.Material.CrackedLava
}

--[[ Loop through the regions 
and fill each one with terrain 
with the material of the correspondent index]]

for Index, Region in ipairs(RegionsWorld1) do
	local CFrame = Region.CFrame
	local Size = Region.Size
	
	Region:Destroy()
	
	Terrain:FillBlock(CFrame, Size, CorrespondentMats[Index])
end

You have to use RaycastResult.Material. So basically, instead of using Mouse.Target, use a raycast pointing from the camera to the mouses position. This raycastResult can return the actual material counting terr4in.

Thanks! The RaycastResult returns the material as grass and the instance as terrain so it works.