if not game:IsLoaded() then game.Loaded:Wait() end local Players = game:GetService('Players') local ReplicatedStorage = game:GetService('ReplicatedStorage') local CollectionService = game:GetService('CollectionService') local Workspace = game:GetService('Workspace') local CoreGui = game:GetService('CoreGui') local LocalPlayer = Players.LocalPlayer -- Knit + OreController local Knit = require(ReplicatedStorage:WaitForChild('Packages'):WaitForChild('Knit')) local OreController repeat pcall(function() Knit.Start() OreController = Knit.GetController('OreController') end) task.wait(0.1) until OreController -- Toggle flag local autoMine = false -- GUI toggle local function createGui() local gui = Instance.new('ScreenGui') gui.Name = 'AutoMineUI' gui.ResetOnSpawn = false gui.IgnoreGuiInset = true pcall(function() gui.Parent = CoreGui end) local button = Instance.new('TextButton') button.Size = UDim2.new(0, 160, 0, 40) button.Position = UDim2.new(0, 20, 0, 20) button.BackgroundColor3 = Color3.fromRGB(50, 50, 50) button.TextColor3 = Color3.new(1, 1, 1) button.Font = Enum.Font.GothamBold button.TextSize = 18 button.Text = 'Auto-Mine: OFF' button.Draggable = true button.Active = true button.Parent = gui button.MouseButton1Click:Connect(function() autoMine = not autoMine button.Text = 'Auto-Mine: ' .. (autoMine and 'ON' or 'OFF') button.BackgroundColor3 = autoMine and Color3.fromRGB(0, 170, 0) or Color3.fromRGB(50, 50, 50) end) end createGui() -- Helpers local function getHRP() local char = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait() return char:WaitForChild('HumanoidRootPart', 5) end local function isOre(model) return model and model:IsA('Model') and model.PrimaryPart and ( CollectionService:HasTag(model, 'Ore') or CollectionService:HasTag(model, 'AfkOre') or (model:GetAttribute('roomId') and model:GetAttribute('id')) ) end local function findNearestOre() local hrp = getHRP() if not hrp then return nil end local bestOre, bestDist = nil, math.huge local function scan(list) for _, obj in pairs(list) do if isOre(obj) then local dist = (obj.PrimaryPart.Position - hrp.Position).Magnitude if dist < bestDist then bestOre = obj bestDist = dist end end end end scan(CollectionService:GetTagged('Ore')) scan(CollectionService:GetTagged('AfkOre')) local debris = Workspace:FindFirstChild('Debris') if debris then scan(debris:GetChildren()) end return bestOre end local function canMine(ore) local ok, res = pcall(function() return OreController:isStrongEnough(ore) end) return ok and res end local function mineOre(ore) if not ore or not ore:IsDescendantOf(Workspace) then return end if not canMine(ore) then return end pcall(function() OreController:moveToOre(ore) task.wait(0.2) OreController:autoDamageOre() end) local timeout = 10 local start = tick() while tick() - start < timeout do if not autoMine then OreController:cancelAutoDamageOre() return end if not ore:IsDescendantOf(Workspace) then break end task.wait(0.1) end pcall(function() OreController:cancelAutoDamageOre() end) end -- Main loop task.spawn(function() while true do if autoMine then local ore = findNearestOre() if ore then mineOre(ore) end end task.wait(0.3) end end)