--[[
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā š¢ļø BARREL AUTOFARM ā
ā Impossible Slap Tower - Executor ā
ā Auto-collect barrels via proximity prompts ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
]]
-- Global toggle ā set to true/false to start/stop
_G.BARREL_AUTOFARM = false
_G.BARREL_AUTOFARM_GEN = 0
-- Services
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
-- Player references
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
-- Re-fetch character on respawn
Player.CharacterAdded:Connect(function(char)
Character = char
HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
end)
-- Configuration
local CONFIG = {
BarrelFolder = workspace:WaitForChild("ToiletZone"):WaitForChild("Barrels"),
SellRemote = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("SellBarrel"),
MaxBarrels = 20, -- auto-sell when barrel count reaches this
TeleportOffset = Vector3.new(0, 3, 0), -- offset above barrel
PostCollectDelay = 2.0, -- wait after firing prompt for server to process
BetweenBarrelDelay = 2.0, -- delay between barrels
RetryDelay = 3.0, -- delay before retrying a failed collect
MaxRetries = 3, -- max retries per barrel
RescanDelay = 2.0, -- delay when no barrels found
SellDelay = 2.0, -- wait after selling for server to process
}
-- State
local State = {
Connections = {},
Collected = 0,
Sold = 0,
Failed = 0,
Status = "Idle",
}
-- UI Colors
local Colors = {
Background = Color3.fromRGB(25, 25, 35),
Panel = Color3.fromRGB(35, 35, 50),
Accent = Color3.fromRGB(100, 149, 237),
AccentDark = Color3.fromRGB(70, 100, 180),
Success = Color3.fromRGB(50, 205, 50),
Error = Color3.fromRGB(220, 50, 50),
Text = Color3.fromRGB(255, 255, 255),
TextDim = Color3.fromRGB(180, 180, 180),
}
-------------------------------------------------------------------------------
-- CORE LOGIC
-------------------------------------------------------------------------------
local function isAlive()
return HumanoidRootPart and HumanoidRootPart.Parent
and Character:FindFirstChildOfClass("Humanoid")
and Character:FindFirstChildOfClass("Humanoid").Health > 0
end
local function teleportTo(position)
if not isAlive() then return false end
HumanoidRootPart.CFrame = CFrame.new(position)
return true
end
local function countBarrelTools()
local count = 0
local player = Players.LocalPlayer
-- Count in backpack
local backpack = player:FindFirstChild("Backpack")
if backpack then
for _, item in ipairs(backpack:GetChildren()) do
if item:IsA("Tool") and item.Name:find("Barrel") then
count = count + 1
end
end
end
-- Count in character
local char = player.Character
if char then
for _, item in ipairs(char:GetChildren()) do
if item:IsA("Tool") and item.Name:find("Barrel") then
count = count + 1
end
end
end
return count
end
local function unequipTool()
local char = Players.LocalPlayer.Character
if not char then return end
local humanoid = char:FindFirstChildOfClass("Humanoid")
if humanoid then humanoid:UnequipTools() end
end
local function findBarrels()
local barrels = {}
for _, child in ipairs(CONFIG.BarrelFolder:GetChildren()) do
if child:IsA("Model") and child.Name == "Barrel" and child:FindFirstChild("Main") then
table.insert(barrels, child)
end
end
return barrels
end
local function triggerPrompt(prompt)
if not prompt or not prompt.Parent then return end
fireproximityprompt(prompt)
end
local function collectBarrel(barrel)
if not barrel or not barrel.Parent then return false end
local mainPart = barrel:FindFirstChild("Main")
if not mainPart then return false end
local prompt = mainPart:FindFirstChildOfClass("ProximityPrompt")
if not prompt or not prompt.Enabled then return false end
-- Unequip any held tool first
unequipTool()
task.wait(0.3)
-- Record barrel count before attempt
local barrelsBefore = countBarrelTools()
-- Teleport directly on top of the barrel
local targetPos = mainPart.Position + CONFIG.TeleportOffset
State.Status = "Moving to barrel..."
if not teleportTo(targetPos) then return false end
-- Fire the proximity prompt with retry logic
for attempt = 1, CONFIG.MaxRetries do
if not _G.BARREL_AUTOFARM then return false end
if not barrel or not barrel.Parent then break end
State.Status = string.format("Firing prompt (attempt %d/%d)...", attempt, CONFIG.MaxRetries)
triggerPrompt(prompt)
task.wait(CONFIG.PostCollectDelay) -- Verify collection by checking inventory
local barrelsAfter = countBarrelTools()
if barrelsAfter > barrelsBefore then
State.Collected += 1
State.Status = string.format("Collected! (%d total)", barrelsAfter)
return true
end
-- Not collected yet ā wait before retry
if attempt < CONFIG.MaxRetries then
State.Status = string.format("Retry %d/%d...", attempt + 1, CONFIG.MaxRetries)
task.wait(CONFIG.RetryDelay)
end
end
-- Failed after all retries
State.Failed += 1
State.Status = "Failed to collect"
return false
end
local function sellBarrels()
State.Status = "Selling barrels..."
unequipTool()
task.wait(0.3)
local barrelsBefore = countBarrelTools()
-- Fire the sell remote
pcall(function()
CONFIG.SellRemote:FireServer("sell")
end)
task.wait(CONFIG.SellDelay)
-- Verify sell
local barrelsAfter = countBarrelTools()
local sold = barrelsBefore - barrelsAfter
if sold > 0 then
State.Sold += sold
State.Status = string.format("Sold %d barrels!", sold)
else
State.Status = "Sell may have failed"
end
end
-------------------------------------------------------------------------------
-- AUTOFARM LOOP
-------------------------------------------------------------------------------
local function autofarmLoop()
local gen = _G.BARREL_AUTOFARM_GEN
while _G.BARREL_AUTOFARM and _G.BARREL_AUTOFARM_GEN == gen do
-- Skip if dead
if not isAlive() then
State.Status = "Waiting for respawn..."
task.wait(0.5)
continue
end
-- Auto-sell when inventory is full
local barrelCount = countBarrelTools()
if barrelCount >= CONFIG.MaxBarrels then
sellBarrels()
task.wait(1.0)
continue
end
local barrels = findBarrels()
if #barrels > 0 then
for _, barrel in ipairs(barrels) do
if not _G.BARREL_AUTOFARM or _G.BARREL_AUTOFARM_GEN ~= gen then break end
-- Check if inventory full mid-loop
if countBarrelTools() >= CONFIG.MaxBarrels then
sellBarrels()
task.wait(1.0)
break
end
collectBarrel(barrel)
task.wait(CONFIG.BetweenBarrelDelay)
end
else
State.Status = "Waiting for barrels..."
task.wait(CONFIG.RescanDelay)
end
end
State.Status = "Idle"
end
-------------------------------------------------------------------------------
-- UI
-------------------------------------------------------------------------------
local function createUI()
-- Clean up old UI
local old = Player.PlayerGui:FindFirstChild("BarrelAutofarmUI")
if old then old:Destroy() end
local gui = Instance.new("ScreenGui")
gui.Name = "BarrelAutofarmUI"
gui.ResetOnSpawn = false
gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
gui.Parent = Player.PlayerGui
-- Main frame
local main = Instance.new("Frame")
main.Name = "Main"
main.Size = UDim2.new(0, 280, 0, 140)
main.Position = UDim2.new(0, 20, 0.5, -70)
main.BackgroundColor3 = Colors.Background
main.BorderSizePixel = 0
main.Parent = gui
Instance.new("UICorner", main).CornerRadius = UDim.new(0, 10)
-- Title bar
local titleBar = Instance.new("Frame")
titleBar.Name = "TitleBar"
titleBar.Size = UDim2.new(1, 0, 0, 36)
titleBar.BackgroundColor3 = Colors.Accent
titleBar.BorderSizePixel = 0
titleBar.Parent = main
local titleCorner = Instance.new("UICorner", titleBar)
titleCorner.CornerRadius = UDim.new(0, 10)
-- Bottom cover so bottom corners stay square
local titleCover = Instance.new("Frame")
titleCover.Size = UDim2.new(1, 0, 0, 10)
titleCover.Position = UDim2.new(0, 0, 1, -10)
titleCover.BackgroundColor3 = Colors.Accent
titleCover.BorderSizePixel = 0
titleCover.Parent = titleBar
local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, -20, 1, 0)
title.Position = UDim2.new(0, 12, 0, 0)
title.BackgroundTransparency = 1
title.Text = "š¢ļø Barrel Autofarm"
title.TextColor3 = Colors.Text
title.TextSize = 15
title.Font = Enum.Font.GothamBold
title.TextXAlignment = Enum.TextXAlignment.Left
title.Parent = titleBar
-- Toggle row
local toggleRow = Instance.new("Frame")
toggleRow.Name = "ToggleRow"
toggleRow.Size = UDim2.new(1, -20, 0, 38)
toggleRow.Position = UDim2.new(0, 10, 0, 46)
toggleRow.BackgroundColor3 = Colors.Panel
toggleRow.BorderSizePixel = 0
toggleRow.Parent = main
Instance.new("UICorner", toggleRow).CornerRadius = UDim.new(0, 8)
local toggleLabel = Instance.new("TextLabel")
toggleLabel.Size = UDim2.new(0.6, 0, 1, 0)
toggleLabel.Position = UDim2.new(0, 12, 0, 0)
toggleLabel.BackgroundTransparency = 1
toggleLabel.Text = "Autofarm"
toggleLabel.TextColor3 = Colors.Text
toggleLabel.TextSize = 13
toggleLabel.Font = Enum.Font.GothamMedium
toggleLabel.TextXAlignment = Enum.TextXAlignment.Left
toggleLabel.Parent = toggleRow
local toggleBtn = Instance.new("TextButton")
toggleBtn.Name = "ToggleButton"
toggleBtn.Size = UDim2.new(0, 56, 0, 26)
toggleBtn.Position = UDim2.new(1, -66, 0.5, -13)
toggleBtn.BackgroundColor3 = Colors.Error
toggleBtn.Text = "OFF"
toggleBtn.TextColor3 = Colors.Text
toggleBtn.TextSize = 12
toggleBtn.Font = Enum.Font.GothamBold
toggleBtn.BorderSizePixel = 0
toggleBtn.Parent = toggleRow
Instance.new("UICorner", toggleBtn).CornerRadius = UDim.new(0, 6)
-- Status row
local statusRow = Instance.new("Frame")
statusRow.Name = "StatusRow"
statusRow.Size = UDim2.new(1, -20, 0, 32)
statusRow.Position = UDim2.new(0, 10, 0, 92)
statusRow.BackgroundColor3 = Colors.Panel
statusRow.BorderSizePixel = 0
statusRow.Parent = main
Instance.new("UICorner", statusRow).CornerRadius = UDim.new(0, 8)
local statusLabel = Instance.new("TextLabel")
statusLabel.Name = "StatusLabel"
statusLabel.Size = UDim2.new(1, -16, 1, 0)
statusLabel.Position = UDim2.new(0, 8, 0, 0)
statusLabel.BackgroundTransparency = 1
statusLabel.Text = "Status: Idle | 0 collected"
statusLabel.TextColor3 = Colors.TextDim
statusLabel.TextSize = 11
statusLabel.Font = Enum.Font.GothamMedium
statusLabel.TextXAlignment = Enum.TextXAlignment.Left
statusLabel.Parent = statusRow
return gui, main, titleBar, toggleBtn, statusLabel
end
-------------------------------------------------------------------------------
-- INIT
-------------------------------------------------------------------------------
local gui, main, titleBar, toggleBtn, statusLabel = createUI()
-- Toggle handler
local function setToggle(on)
if on then
_G.BARREL_AUTOFARM_GEN = _G.BARREL_AUTOFARM_GEN + 1
end
_G.BARREL_AUTOFARM = on
if on then
toggleBtn.BackgroundColor3 = Colors.Success
toggleBtn.Text = "ON"
State.Status = "Starting..."
task.spawn(autofarmLoop)
else
toggleBtn.BackgroundColor3 = Colors.Error
toggleBtn.Text = "OFF"
State.Status = "Stopping..."
task.wait(0.3)
State.Status = "Idle"
end
end
toggleBtn.MouseButton1Click:Connect(function()
setToggle(not _G.BARREL_AUTOFARM)
end)
-- Dragging
local dragging, dragInput, dragStart, startPos
titleBar.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = main.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
titleBar.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
dragInput = input
end
end)
UserInputService.InputChanged:Connect(function(input)
if input == dragInput and dragging then
local delta = input.Position - dragStart
main.Position = UDim2.new(
startPos.X.Scale, startPos.X.Offset + delta.X,
startPos.Y.Scale, startPos.Y.Offset + delta.Y
)
end
end)
-- Hover effects
titleBar.MouseEnter:Connect(function()
titleBar.BackgroundColor3 = Colors.AccentDark
end)
titleBar.MouseLeave:Connect(function()
titleBar.BackgroundColor3 = Colors.Accent
end)
-- UI update loop
task.spawn(function()
while gui.Parent do
statusLabel.Text = string.format("Status: %s | %d ok / %d sold / %d fail", State.Status, State.Collected, State.Sold, State.Failed)
task.wait(0.1)
end
end)
-- Cleanup on destroy
gui.Destroying:Connect(function()
_G.BARREL_AUTOFARM = false
end)
-- Expose toggle globally for remote activation
_G.ToggleBarrelAutofarm = setToggle
print("š¢ļø Barrel Autofarm loaded ā click the toggle to start!")
print(" Global variable: _G.BARREL_AUTOFARM (true/false)")
print(" Remote toggle: _G.ToggleBarrelAutofarm(true/false)")