Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Var
- local moveStud = 15
- local buyMuch = 3
- local buyParent = "Volcano"
- local buyList = {"Volcanic Luck Potion", "Volcanic Strength Potion"}
- --local NPCSell = "Cavern"
- local maxBackpack = 450
- local listSafe = {"Uranium", "Cinnabar", "Diamond", "Aetherite", "Flarebloom", "Volcanic Core", "Prismara", "Vortessence", "Inferlume", "Painite", "Pink Diamond", "Dinosaur Skull"}
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RunService = game:GetService("RunService")
- local player = Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local PlayerGui = player:WaitForChild("PlayerGui")
- local humanoid = character:WaitForChild("Humanoid")
- local animator = humanoid:WaitForChild("Animator")
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- print("[+] Character loaded:", character)
- local tool = character:FindFirstChildOfClass("Tool")
- if not tool then
- warn("- Pan tidak ditemukan.")
- return
- end
- print("[+] Tool loaded:", tool)
- local scriptsFolder = tool:FindFirstChild("Scripts")
- if not scriptsFolder then
- warn("- Folder Scripts tidak ditemukan dalam tool.")
- return
- end
- -- Move
- local startFrame = humanoidRootPart.CFrame
- local startPos = humanoidRootPart.Position
- local startLook = startFrame - startPos
- -- Dig
- local collectRemote = scriptsFolder:FindFirstChild("Collect")
- local toggleRemote = scriptsFolder:WaitForChild("ToggleShovelActive")
- -- Pan
- local panRemote = scriptsFolder:WaitForChild("Pan")
- local shakeRemote = scriptsFolder:WaitForChild("Shake")
- -- Sell
- local backpack = player:WaitForChild("Backpack")
- local isiBackpack = #backpack:GetChildren()
- local ShopRemotes = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("Shop")
- local merchant = workspace:WaitForChild("NPCs"):WaitForChild("Mountain"):GetChildren()[5]
- -- Buy Item
- -- Animations
- local panningAnims = ReplicatedStorage.Assets.Animations.Panning
- local animWindUp = animator:LoadAnimation(panningAnims.DigWindUp)
- local animDig = animator:LoadAnimation(panningAnims.Dig)
- local animHit = animator:LoadAnimation(panningAnims.DigHit)
- local animWash = animator:LoadAnimation(panningAnims.Wash)
- local animShake = animator:LoadAnimation(panningAnims.Shake)
- -- UI
- local fillingUI = PlayerGui:WaitForChild("ToolUI").DigBar
- local fillLine = fillingUI:WaitForChild("Line")
- -- Attribute references
- local stats = player:WaitForChild("Stats")
- local capacity = stats:GetAttribute("Capacity")
- local digSpeed = stats:GetAttribute("DigSpeed")
- -- Sounds
- local handle = tool:WaitForChild("Handle")
- local digSound = handle:WaitForChild("Dig")
- local perfectSound = scriptsFolder:WaitForChild("Sounds"):WaitForChild("PerfectDig")
- -- Flags
- local isDigging = false
- local running = false
- local needDig = true
- local maxStuck = 10
- local countStuck = 0
- local function moveRelative(stud)
- -- Hitung posisi target
- local targetPos = humanoidRootPart.Position + humanoidRootPart.CFrame.LookVector * stud
- -- Gerakkan
- humanoid:MoveTo(targetPos)
- local reached = false
- humanoid.MoveToFinished:Connect(function()
- reached = true
- end)
- local timeout = 5
- local start = tick()
- while not reached and tick() - start < timeout do
- task.wait(0.1)
- end
- -- Kembalikan arah hadap awal
- humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position) * startLook
- end
- local function moveToNoTime(targetPoint)
- local targetReached = false
- -- listen for the humanoid reaching its target
- local connection
- connection = humanoid.MoveToFinished:Connect(function(reached)
- targetReached = true
- connection:Disconnect()
- connection = nil
- end)
- -- start walking
- humanoid:MoveTo(targetPoint)
- while not targetReached do
- -- does the humanoid still exist?
- if not (humanoid and humanoid.Parent) then
- break
- end
- -- has the target changed?
- if humanoid.WalkToPoint ~= targetPoint then
- break
- end
- -- refresh the timeout
- humanoid:MoveTo(targetPoint)
- task.wait(6)
- end
- -- disconnect the connection if it is still connected
- if connection then
- connection:Disconnect()
- connection = nil
- end
- end
- local function stringInArray(str, arr)
- for _, v in ipairs(arr) do
- if v == str then
- return true
- end
- end
- return false
- end
- local function safeInventory(name)
- for num, itemBackpack in ipairs(backpack:GetChildren()) do
- local itemType = itemBackpack:GetAttribute("ItemType")
- local locked = itemBackpack:GetAttribute("Locked")
- if itemType == "Valuable" and not locked and stringInArray(itemBackpack.Name, name) then
- ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("Inventory"):WaitForChild("ToggleLock"):FireServer(itemBackpack)
- break
- end
- end
- end
- local function startDigging()
- local panFill = tool:GetAttribute("Fill") or 0
- if isDigging then return end
- if panFill >= capacity then
- countStuck += 1
- needDig = false
- return
- end
- isDigging = true
- local digSh = toggleRemote:FireServer(true)
- -- Show UI
- fillingUI.Visible = true
- fillLine.Position = UDim2.new(0.5, 0, 1, 0)
- local collect = collectRemote:InvokeServer()
- if collect then
- local reachedPerfect = false
- local progress = 0
- local clamped
- while isDigging do
- local delta = RunService.Heartbeat:Wait()
- progress = progress + digSpeed * 1.5 * delta
- clamped = math.clamp(progress, 0, 1)
- fillLine.Position = UDim2.new(0.5, 0, 1 - clamped, 0)
- if clamped >= 1 then break end
- end
- task.wait(0.17 / digSpeed)
- -- Final invoke
- task.spawn(function()
- collectRemote:InvokeServer(1)
- end)
- task.wait(0.95 / digSpeed)
- countStuck = 0
- isDigging = false
- else
- countStuck += 1
- warn("[+] Digging: Failed")
- end
- fillingUI.Visible = false
- toggleRemote:FireServer(false)
- task.wait(1)
- end
- local function startPanning()
- local fill = tool:GetAttribute("Fill")
- -- Mulai Panning
- local result = panRemote:InvokeServer()
- if result then
- -- Mainkan animasi awal
- animWash:Play()
- task.wait(0.35) -- sesuai PanClient
- -- Mainkan animasi shake
- animShake:Play()
- animShake:AdjustSpeed(1)
- -- Loop shake hingga pan kosong
- while fill > 0 do
- shakeRemote:FireServer()
- task.wait(0.5)
- fill = tool:GetAttribute("Fill") or 0
- end
- -- Hentikan animasi shake
- animShake:Stop()
- animWash:Stop()
- countStuck = 0
- needDig = true
- else
- countStuck += 1
- warn("[+] Panning: Failed")
- end
- end
- local function buyThing(list, amount)
- for numBuy, itemBuy in ipairs(list) do
- for numMuch = 1, amount, 1 do
- local itemToBuy = workspace:WaitForChild("Purchasable"):WaitForChild(buyParent):WaitForChild(itemBuy):WaitForChild("ShopItem")
- ShopRemotes:WaitForChild("BuyItem"):InvokeServer(itemToBuy)
- task.wait(0.5)
- end
- end
- end
- local function sellAll(tpBack)
- local prompt = merchant:FindFirstChild("DialogPrompt")
- if not prompt then
- warn("- Tidak ditemukan ProximityPrompt pada NPC Merchant")
- return
- end
- -- MOVE
- local targetNPC = merchant.HumanoidRootPart.CFrame.Position + (merchant.HumanoidRootPart.CFrame.LookVector * 4)
- moveToNoTime(targetNPC)
- task.wait(5)
- fireproximityprompt(prompt)
- local sellPrice = ShopRemotes:WaitForChild("GetInventorySellPrice"):InvokeServer()
- local sellAll = ShopRemotes:WaitForChild("SellAll")
- if sellPrice then
- task.wait(5)
- sellAll:InvokeServer()
- -- MOVE
- moveToNoTime(tpBack.Position)
- humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position) * startLook
- else
- warn("[+] Sell All: Failed")
- end
- end
- local function runningLoop(backFrame)
- while running and countStuck < maxStuck do
- isiBackpack = #backpack:GetChildren()
- --print("- Backpack:", isiBackpack)
- if isiBackpack < maxBackpack then
- while needDig do
- startDigging()
- end
- task.wait(3)
- moveRelative(moveStud)
- task.wait(3)
- startPanning()
- task.wait(3)
- moveRelative(-moveStud)
- task.wait(2)
- safeInventory(listSafe)
- task.wait(2)
- else
- task.wait(3)
- sellAll(backFrame)
- task.wait(2)
- buyThing(buyList, buyMuch)
- task.wait(2)
- end
- end
- end
- -- UI
- local gui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
- gui.Name = "AutoFarmGUI"
- local frame = Instance.new("Frame", gui)
- frame.Size = UDim2.new(0, 150, 0, 100)
- frame.Position = UDim2.new(0, 10, 0.5, -50)
- frame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- frame.BorderSizePixel = 0
- frame.BackgroundTransparency = 0.2
- local toggleBtn = Instance.new("TextButton", frame)
- toggleBtn.Size = UDim2.new(1, -10, 0.4, -5)
- toggleBtn.Position = UDim2.new(0, 5, 0, 5)
- toggleBtn.Text = "Start"
- toggleBtn.BackgroundColor3 = Color3.fromRGB(100, 200, 100)
- local endBtn = Instance.new("TextButton", frame)
- endBtn.Size = UDim2.new(1, -10, 0.4, -5)
- endBtn.Position = UDim2.new(0, 5, 0.55, 0)
- endBtn.Text = "End Script"
- endBtn.BackgroundColor3 = Color3.fromRGB(200, 100, 100)
- -- Button Events
- toggleBtn.MouseButton1Click:Connect(function()
- running = not running
- if running then
- local newStartFrame = humanoidRootPart.CFrame
- toggleBtn.Text = "Running..."
- runningLoop(newStartFrame)
- else
- toggleBtn.Text = "Start"
- end
- end)
- endBtn.MouseButton1Click:Connect(function()
- running = false
- gui:Destroy()
- end)
Advertisement
Add Comment
Please, Sign In to add comment