Auto Farm
Key Required

Auto Farm

Treasure Hunt SimulatorJustShareJustShare 9.3K views 625 executesUpdated Jan 25, 2025
2.5/ 5(2 votes)
1150% Positive
Lua Script•260 lines (9551 chars)
---------- [ Library ] ----------
local Library = loadstring(game:HttpGet("https://pastebin.com/raw/b5QLVFiM"))()

---------- [ Window ] ----------
local Window = Library:CreateWindow('JustShare - Hub')

---------- [ Create Tab ] ----------
local Tab = {
    Home = Window:addTab('•Home + Settings'),
}

---------- [ Home Tab Section ] ----------
local Home_Right = Tab.Home:addSection()
local Main_Home = Home_Right:addMenu("#Home")

---------- [ Variables ] ----------
local Farm = false
local AutoSellEnabled = false
local Rebirth = false
local IsSelling = false
local FarmPaused = false
local CurrentChest = nil
local FarmingSpeed = 0.001  -- Mengatur farming speed menjadi 0.001
local VisualEffectsEnabled = true
local ESPEnabled = false
local ChestHighlights = {}

---------- [ Sell Function ] ----------
local function Sell()
    if IsSelling then return end
    IsSelling = true

    local OldPos = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
    game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(3, 10, -160)
    wait(0.1)
    game.ReplicatedStorage.Events.AreaSell:FireServer()
    wait(0.1)

    game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = OldPos
    game:GetService("StarterGui"):SetCore("SendNotification", {
        Title = "Success!",
        Text = "Sand sold successfully!",
        Duration = 5,
    })

    IsSelling = false
end

---------- [ Auto Farm Loop ] ----------
local function AutoFarmLoop()
    while Farm do
        if FarmPaused then
            wait(0.1)
        else
            -- Memastikan tool ada di tangan
            local tool = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Tool") or 
                         game.Players.LocalPlayer.Backpack:FindFirstChildOfClass("Tool")

            -- Pastikan tool tersedia sebelum melanjutkan
            if not tool then
                game:GetService("StarterGui"):SetCore("SendNotification", {
                    Title = "Error!",
                    Text = "No tool found! Disabling Auto Farm.",
                    Duration = 5,
                })
                Farm = false
                return
            elseif not game.Players.LocalPlayer.Character:FindFirstChildOfClass("Tool") then
                game.Players.LocalPlayer.Character.Humanoid:EquipTool(tool)
                wait(0.1)
            end

            -- Fokuskan posisi karakter hanya pada chest yang sedang di-farm
            if CurrentChest and CurrentChest.Parent then
                local humanoidRootPart = game.Players.LocalPlayer.Character.HumanoidRootPart
                local targetPosition = CurrentChest.Position

                -- Pindahkan karakter ke chest dengan kecepatan lebih tinggi
                if (humanoidRootPart.Position - targetPosition).Magnitude > 0.5 then
                    humanoidRootPart.CFrame = CFrame.new(targetPosition)
                end

                tool.RemoteClick:FireServer(CurrentChest)
                wait(FarmingSpeed)

                -- Cek apakah Backpack penuh dan jual otomatis jika perlu
                if AutoSellEnabled and game.Players.LocalPlayer.PlayerGui.Gui.Popups.BackpackFull.Visible then
                    FarmPaused = true
                    Sell()
                    FarmPaused = false
                end
            else
                -- Jika Chest tidak ditemukan, lakukan pencarian chest baru
                CurrentChest = nil
                for _, v in pairs(game.Workspace.SandBlocks:GetChildren()) do
                    if not Farm then break end
                    if v:FindFirstChild("Chest") then
                        CurrentChest = v
                        v.CanCollide = false
                        local character = game.Players.LocalPlayer.Character
                        if character then
                            -- Fokuskan posisi karakter pada chest baru
                            local humanoidRootPart = game.Players.LocalPlayer.Character.HumanoidRootPart
                            local targetPosition = v.Position
                            
                            -- Pindahkan posisi karakter hanya jika diperlukan
                            if (humanoidRootPart.Position - targetPosition).Magnitude > 0.5 then
                                humanoidRootPart.CFrame = CFrame.new(targetPosition)
                            end

                            tool.RemoteClick:FireServer(v)
                            wait(0.05)
                        end
                        break
                    end
                end
            end
        end
        wait(0.05) 
    end
end

---------- [ Toggling Features ] ----------
-- Auto Farm Toggle
Main_Home:addToggle('Auto Farm', false, function(state)
    Farm = state
    if state then
        -- Cek apakah tool sudah ada di karakter
        local tool = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Tool")
        if not tool then
            tool = game.Players.LocalPlayer.Backpack:FindFirstChildOfClass("Tool")
        end
        
        if not tool then
            game:GetService("StarterGui"):SetCore("SendNotification", {
                Title = "Error!",
                Text = "No tool found! Auto Farm disabled.",
                Duration = 5,
            })
            Farm = false
            return
        end

        -- Jika tool tidak ada di karakter, equip tool dari backpack
        if not game.Players.LocalPlayer.Character:FindFirstChildOfClass("Tool") then
            game.Players.LocalPlayer.Character.Humanoid:EquipTool(tool)
            wait(0.1)
        end

        game:GetService("StarterGui"):SetCore("SendNotification", {
            Title = "Success!",
            Text = "Auto Farm enabled.",
            Duration = 5,
        })
        spawn(AutoFarmLoop)
    else
        game:GetService("StarterGui"):SetCore("SendNotification", {
            Title = "Info!",
            Text = "Auto Farm disabled.",
            Duration = 5,
        })
    end
end)

-- Auto Sell Toggle
Main_Home:addToggle('Auto Sell', false, function(state)
    AutoSellEnabled = state
    game:GetService("StarterGui"):SetCore("SendNotification", {
        Title = state and "Enabled!" or "Disabled!",
        Text = "Auto Sell " .. (state and "enabled." or "disabled."),
        Duration = 5,
    })
end)

---------- [ Misc Tab Section ] ----------
local Misc_Left = Tab.Home:addSection()
local Main_Misc = Misc_Left:addMenu("#Settings")

---------- [ Misc - Farming Speed Textbox ] ----------
Main_Misc:addTextbox('Farming Speed', tostring(FarmingSpeed), function(value)
    local newFarmingSpeed = tonumber(value)
    if newFarmingSpeed and newFarmingSpeed > 0 then
        FarmingSpeed = newFarmingSpeed
        game:GetService("StarterGui"):SetCore("SendNotification", {
            Title = "Farming Speed Updated!",
            Text = "Farming speed set to: " .. tostring(newFarmingSpeed),
            Duration = 5,
        })
    else
        game:GetService("StarterGui"):SetCore("SendNotification", {
            Title = "Invalid Input",
            Text = "Please enter a valid positive number for Farming Speed.",
            Duration = 5,
        })
    end
end)

---------- [ Misc - ESP Chest Toggle ] ----------
Main_Misc:addToggle('ESP Chest', false, function(state)
    ESPEnabled = state

    if state then
        for _, v in pairs(game.Workspace.SandBlocks:GetChildren()) do
            if v:FindFirstChild("Chest") then
                local highlight = Instance.new("Highlight")
                highlight.Parent = v
                highlight.Adornee = v
                highlight.FillColor = Color3.fromRGB(255, 0, 0)
                highlight.FillTransparency = 0.5
                highlight.OutlineColor = Color3.fromRGB(255, 255, 255)
                highlight.OutlineTransparency = 0.5
                table.insert(ChestHighlights, highlight)
            end
        end
    else
        for _, highlight in pairs(ChestHighlights) do
            highlight:Destroy()
        end
        ChestHighlights = {}
    end
end)

-- Update ESP
spawn(function()
    while true do
        if ESPEnabled then
            for _, v in pairs(game.Workspace.SandBlocks:GetChildren()) do
                if v:FindFirstChild("Chest") then
                    local highlightExists = false
                    for _, highlight in pairs(ChestHighlights) do
                        if highlight.Adornee == v then
                            highlightExists = true
                            break
                        end
                    end

                    if not highlightExists then
                        local highlight = Instance.new("Highlight")
                        highlight.Parent = v
                        highlight.Adornee = v
                        highlight.FillColor = Color3.fromRGB(255, 0, 0)
                        highlight.FillTransparency = 0.5
                        highlight.OutlineColor = Color3.fromRGB(255, 255, 255)
                        highlight.OutlineTransparency = 0.5
                        table.insert(ChestHighlights, highlight)
                    end
                end
            end

            for i = #ChestHighlights, 1, -1 do
                local highlight = ChestHighlights[i]
                if not highlight.Adornee or not highlight.Adornee.Parent then
                    highlight:Destroy()
                    table.remove(ChestHighlights, i)
                end
            end
        end
        wait(1)
    end
end)

Features & Information

+ Auto Farm Chest + Auto Sell (Smooth) + X-Ray And more feature coming soon
#Free#Open source

Community Comments (0)

No comments yet for this script.

More Scripts for Treasure Hunt Simulator