I found this dig script which digs terrain. How would I edit the code so that it digs parts which are a certain material and aren't terrain basically a part which is a sand material. For example, make a part transparency = 1 and can collide = false so the part is removed fully.
mouse = game.Players.LocalPlayer:GetMouse()
down = false
mouse.Button1Down:connect(function ()
down = true
mouse.Button1Up:connect(function ()
down = false
end)
local recordedPosition = game.Workspace.Terrain:WorldToCellPreferSolid(mouse.Hit.p)
local gui = script.Dig:clone()
gui.Parent = game.Players.LocalPlayer.PlayerGui
for i = 1,33 do
if game.Workspace.Terrain:WorldToCellPreferSolid(mouse.Hit.p) ~= recordedPosition then
gui:Destroy()
return
end
if down == false then
gui:Destroy()
return
end
gui.Progress.Bar.Size = UDim2.new(0.03*i,0,1,0)
wait()
end
gui:Destroy()
game.Workspace.Terrain:SetCell(recordedPosition.X,recordedPosition.Y,recordedPosition.Z,0,0,0)
end)
Thank You and Help is appreciated

2 comments
Setting transparency to 1 and cancollide to false does not remove the part it just makes it invisible. You should try something easier you obviously don't have the skills for this
or part:Destroy()