Hi, Guys, I made a shovel script that allows you to dig in the smooth terrain however there is a problem when it comes to digging grass, it is just not working (Works with different materials fine).
Here is script:
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local tool = script.Parent.Parent.Parent.Shovel
local vector = Vector3.new(1,1,1)
local resolution = 4
local digremote = game.ReplicatedStorage:WaitForChild("Dig")
local function GetDistance(p1,p2)
local Distance = (p1.Position - p2.Position).magnitude
return Distance
end
tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
if mouse.Target and mouse.Target.Parent then
if(mouse.Target.Name == "Terrain") then
local Mpos = mouse.hit.p
local MRegion = Region3.new(mouse.hit.p - vector,mouse.hit.p + Vector3.new(1,1,1))
MRegion = MRegion:ExpandToGrid(resolution)
local material = workspace.Terrain:ReadVoxels(MRegion,resolution)
local size = material.Size
for x = 1, size.X do
for y = 1, size.Y do
for z = 1, size.Z do
local mat = material[x][y][z]
if mat == Enum.Material.Cobblestone or mat == Enum.Material.Grass or mat == Enum.Material.Mud then
if GetDistance(mouse.hit, localPlayer.Character.HumanoidRootPart) < 10 then
digremote:FireServer(mouse.hit.p)
end
end
end
end
end
end
end
end)
end)