auto collect barrel for fruit
Key Required

auto collect barrel for fruit

[Alpha] One Piece: Mythicalkwaesway32kwaesway32 8.8K views 438 executesUpdated Sep 8, 2025
0.0/ 5(2 votes)
020% Positive
Lua Script•131 lines (4142 chars)
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local StarterGui = game:GetService("StarterGui")

-- Paths
local BarrelsFolder = workspace.Barrels.Barrels

-- Settings
local HIGH_ALTITUDE = 500
local HORIZ_STEP = 50
local HORIZ_DELAY = 0.02
local VERT_STEP = 2
local VERT_DELAY = 0.01
local CLICK_OFFSET = 2
local CLICK_RETRIES = 3
local COOLDOWN = 15
local TARGET_TIMEOUT = 5 -- max seconds per target

local barrelCooldowns = {}
local autoFarmEnabled = true -- starts on

-- PC toggle: press F
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.F then
            autoFarmEnabled = not autoFarmEnabled
            print("Auto-farm toggled:", autoFarmEnabled)
        end
    end
end)

-- Mobile / GUI toggle button
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "AutoFarmToggleGui"
screenGui.ResetOnSpawn = false
screenGui.Parent = player:WaitForChild("PlayerGui")

local button = Instance.new("TextButton")
button.Size = UDim2.new(0, 150, 0, 50)
button.Position = UDim2.new(0, 20, 0, 20)
button.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
button.TextColor3 = Color3.fromRGB(255, 255, 255)
button.Text = autoFarmEnabled and "AutoFarm: ON" or "AutoFarm: OFF"
button.Parent = screenGui

button.MouseButton1Click:Connect(function()
    autoFarmEnabled = not autoFarmEnabled
    button.Text = autoFarmEnabled and "AutoFarm: ON" or "AutoFarm: OFF"
end)

-- Move horizontally high above map
local function moveHighTo(targetPos)
    local startPos = hrp.Position
    local startHigh = Vector3.new(startPos.X, HIGH_ALTITUDE, startPos.Z)
    local targetHigh = Vector3.new(targetPos.X, HIGH_ALTITUDE, targetPos.Z)
    local direction = (targetHigh - startHigh).Unit
    local distance = (targetHigh - startHigh).Magnitude
    local steps = math.floor(distance / HORIZ_STEP)
    for i = 1, steps do
        if not autoFarmEnabled then return false end
        local stepPos = startHigh + direction * (i * HORIZ_STEP)
        hrp.CFrame = CFrame.new(stepPos)
        wait(HORIZ_DELAY)
    end
    if autoFarmEnabled then
        hrp.CFrame = CFrame.new(targetHigh)
        return true
    else
        return false
    end
end

-- Descend slowly above target
local function descendToTarget(targetPos)
    local targetY = targetPos.Y + CLICK_OFFSET
    local startTime = tick()
    while hrp.Position.Y > targetY do
        if not autoFarmEnabled then return false end
        if tick() - startTime > TARGET_TIMEOUT then return false end
        hrp.CFrame = CFrame.new(hrp.Position.X, math.max(hrp.Position.Y - VERT_STEP, targetY), hrp.Position.Z)
        wait(VERT_DELAY)
    end
    return true
end

-- Click target safely with retries
local function clickTarget(target)
    if not target or not target:IsA("BasePart") then return end
    local lastClick = barrelCooldowns[target] or 0
    if tick() - lastClick < COOLDOWN then return end

    local targetPos = target.Position

    -- Move high
    if not moveHighTo(targetPos) then return end

    -- Descend
    if not descendToTarget(targetPos) then return end

    -- Attempt clicks
    local clickDetector = target:FindFirstChildOfClass("ClickDetector")
    if clickDetector then
        for i = 1, CLICK_RETRIES do
            if not autoFarmEnabled then return end
            fireclickdetector(clickDetector, 0)
            wait(0.05)
        end
        barrelCooldowns[target] = tick()
    end
end

-- Auto-farm function in a coroutine
local function autoFarm()
    while true do
        if autoFarmEnabled then
            -- Barrels only
            for _, barrel in ipairs(BarrelsFolder:GetChildren()) do
                if not autoFarmEnabled then break end
                clickTarget(barrel)
            end
        end
        wait(0.1)
    end
end

-- Start auto-farm
coroutine.wrap(autoFarm)()

Features & Information

made by chatgpt as usual - toggle on/off by click F. on mobile theres a button - use noclip to go through wall, it works better -work best with luck fruit so everytime u collect a barrel u get 2-3 fruit not one - u may get ban so maybe use an alt and give it to ur main or something idk

Community Comments (4)

AriOTR1868AriOTR1868Sep 8, 2025

what ai yall using unc

Replying to @AriOTR1868
kwaesway32kwaesway32Sep 8, 2025

@AriOTR1868 chatgpt

Replying to @kwaesway32
AriOTR1868AriOTR1868Sep 8, 2025

@kwaesway32 unc what chatgpt you got my chagpt cant make even a simple script

raymondgolpeo2raymondgolpeo2Sep 8, 2025

The game is broken for me I can't even hit those crabs like what the heck do I do there

More Scripts for [Alpha] One Piece: Mythical