Roblox Script Wild West Ore Auto Mine

-- Meanwhile dont use your main account
-- Credits to ThisStuff and saucekid
-- Equip your pickaxe to activate

local Players = game:service'Players'
local ReplicatedStorage = game:service'ReplicatedStorage'
local LocalPlayer = Players.LocalPlayer

-- Load Modules
local Modules = require(ReplicatedStorage.Modules.Load)
local SharedModules = require(ReplicatedStorage.SharedModules.Load)
local PlayerCharacter = Modules("PlayerCharacter")

-- Main Script
while wait() do
    if string.match(PlayerCharacter:GetEquippedItem().Name, "Pickaxe") then
        for a,b in next, workspace["WORKSPACE_Interactables"].Mining.OreDeposits:GetDescendants() do
            if string.match(b.Name, "Ore") and b.Parent:FindFirstChild("DepositInfo") and b.Parent.DepositInfo:FindFirstChild("OreRemaining") and b.Parent.DepositInfo.OreRemaining.Value ~= 0 and LocalPlayer.Character:FindFirstChild("Head") and not b:IsA("RayValue") then
                if (LocalPlayer.Character.Head.Position-b.Position).Magnitude <  10 then -- make sure ur 10 studs away
                    PlayerCharacter:GetEquippedItem():NetworkActivate("MineDeposit", b.Parent, b.Position, LocalPlayer.Character.Head.Position)
                else
                    print("too far from ore")
                end
            end
        end
    end
end