Overall, I need a shovel to dig only specific materials, these are: grass, leafy grass, snow, sand. Is it possible to be done on roblox? If so, where’s the error could be at?
function fill(player,blob)
if Enum.Material.Grass or Enum.Material.Snow or Enum.Material.LeafyGrass or Enum.Material.Sand then
workspace.Terrain:FillBlock(CFrame.new(blob),Vector3.new(7,7,7),--[[mouse.Target.Material]]Enum.Material.Air)
else
print("no")
end
end
script.Parent.glob.OnServerEvent:Connect(fill)
It looks like you arent comparing the materials to anything, and that you’re just checking if an enum exists, which will always be true, try adding if SelectedObject.Material == Enum.Material.Grass then (do the rest)
Better yet, you could put all the enums of the materials in a table, create a function to check it, and return true or false if it matches the other materials.
local AcceptedMaterialTable = {Enum.Material.Grass,
Enum.Material.Snow,
Enum.Material.LeafyGrass,
Enum.Material.Sand}
local function CheckMaterial(Object)
for _,Value in pairs(AcceptedMaterialTable) do
if Value == Object.Material then
return true
end
end
return false
end
If the above returns true, that means its a match.