Autofarm
Key Required

Autofarm

[WORLD 4!] 1 Plank = $1/sCasualdeveloperCasualdeveloper 992 views 40 executesUpdated Apr 24, 2026
5.0/ 5(3 votes)
30100% Positive
Lua Script•223 lines (7911 chars)
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

if PlayerGui:FindFirstChild("AutoFarmUI") then
    PlayerGui.AutoFarmUI:Destroy()
end

local farmActive = false
local farmConnection = nil
local lagConnection = nil
local currentMode = "safe"
local stepEvent = nil

local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "AutoFarmUI"
ScreenGui.ResetOnSpawn = false
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
ScreenGui.Parent = PlayerGui

local Main = Instance.new("Frame")
Main.Size = UDim2.new(0, 250, 0, 185)
Main.Position = UDim2.new(0.5, -125, 0.04, 0)
Main.BackgroundColor3 = Color3.fromRGB(15, 15, 20)
Main.BackgroundTransparency = 0.2
Main.BorderSizePixel = 0
Main.Active = true
Main.Draggable = true
Main.Parent = ScreenGui
Instance.new("UICorner", Main).CornerRadius = UDim.new(0, 12)

local Stroke = Instance.new("UIStroke", Main)
Stroke.Color = Color3.fromRGB(60, 60, 80)
Stroke.Thickness = 1

local TitleBar = Instance.new("Frame")
TitleBar.Size = UDim2.new(1, 0, 0, 40)
TitleBar.BackgroundColor3 = Color3.fromRGB(22, 22, 32)
TitleBar.BackgroundTransparency = 0.2
TitleBar.BorderSizePixel = 0
TitleBar.Parent = Main
Instance.new("UICorner", TitleBar).CornerRadius = UDim.new(0, 12)

local TitleFix = Instance.new("Frame")
TitleFix.Size = UDim2.new(1, 0, 0.5, 0)
TitleFix.Position = UDim2.new(0, 0, 0.5, 0)
TitleFix.BackgroundColor3 = Color3.fromRGB(22, 22, 32)
TitleFix.BackgroundTransparency = 0.2
TitleFix.BorderSizePixel = 0
TitleFix.Parent = TitleBar

local Title = Instance.new("TextLabel")
Title.Size = UDim2.new(1, -24, 1, 0)
Title.Position = UDim2.new(0, 14, 0, 0)
Title.BackgroundTransparency = 1
Title.Text = "Auto Farm"
Title.TextColor3 = Color3.fromRGB(220, 220, 240)
Title.TextSize = 14
Title.Font = Enum.Font.GothamBold
Title.TextXAlignment = Enum.TextXAlignment.Left
Title.Parent = TitleBar

local StatusLabel = Instance.new("TextLabel")
StatusLabel.Size = UDim2.new(1, -24, 0, 20)
StatusLabel.Position = UDim2.new(0, 12, 0, 48)
StatusLabel.BackgroundTransparency = 1
StatusLabel.Text = "Status: Idle"
StatusLabel.TextColor3 = Color3.fromRGB(120, 120, 140)
StatusLabel.TextSize = 12
StatusLabel.Font = Enum.Font.Gotham
StatusLabel.TextXAlignment = Enum.TextXAlignment.Left
StatusLabel.Parent = Main

local LagWarning = Instance.new("TextLabel")
LagWarning.Size = UDim2.new(1, -24, 0, 18)
LagWarning.Position = UDim2.new(0, 12, 0, 67)
LagWarning.BackgroundTransparency = 1
LagWarning.Text = ""
LagWarning.TextColor3 = Color3.fromRGB(255, 80, 80)
LagWarning.TextSize = 11
LagWarning.Font = Enum.Font.GothamSemibold
LagWarning.TextXAlignment = Enum.TextXAlignment.Left
LagWarning.Parent = Main

local ModeContainer = Instance.new("Frame")
ModeContainer.Size = UDim2.new(1, -24, 0, 36)
ModeContainer.Position = UDim2.new(0, 12, 0, 90)
ModeContainer.BackgroundColor3 = Color3.fromRGB(30, 30, 40)
ModeContainer.BackgroundTransparency = 0.2
ModeContainer.BorderSizePixel = 0
ModeContainer.Parent = Main
Instance.new("UICorner", ModeContainer).CornerRadius = UDim.new(0, 8)

local SafeBtn = Instance.new("TextButton")
SafeBtn.Size = UDim2.new(0.5, -4, 1, -8)
SafeBtn.Position = UDim2.new(0, 4, 0, 4)
SafeBtn.BackgroundColor3 = Color3.fromRGB(80, 60, 200)
SafeBtn.BorderSizePixel = 0
SafeBtn.Text = "slow"
SafeBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
SafeBtn.TextSize = 11
SafeBtn.Font = Enum.Font.GothamSemibold
SafeBtn.Parent = ModeContainer
Instance.new("UICorner", SafeBtn).CornerRadius = UDim.new(0, 6)

local FastBtn = Instance.new("TextButton")
FastBtn.Size = UDim2.new(0.5, -4, 1, -8)
FastBtn.Position = UDim2.new(0.5, 0, 0, 4)
FastBtn.BackgroundColor3 = Color3.fromRGB(40, 40, 55)
FastBtn.BorderSizePixel = 0
FastBtn.Text = "Fast (Lag + Audio)"
FastBtn.TextColor3 = Color3.fromRGB(180, 180, 180)
FastBtn.TextSize = 11
FastBtn.Font = Enum.Font.GothamSemibold
FastBtn.Parent = ModeContainer
Instance.new("UICorner", FastBtn).CornerRadius = UDim.new(0, 6)

local ToggleBtn = Instance.new("TextButton")
ToggleBtn.Size = UDim2.new(1, -24, 0, 40)
ToggleBtn.Position = UDim2.new(0, 12, 0, 135)
ToggleBtn.BackgroundColor3 = Color3.fromRGB(80, 60, 200)
ToggleBtn.BorderSizePixel = 0
ToggleBtn.Text = "Start Farming"
ToggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
ToggleBtn.TextSize = 13
ToggleBtn.Font = Enum.Font.GothamSemibold
ToggleBtn.Parent = Main
Instance.new("UICorner", ToggleBtn).CornerRadius = UDim.new(0, 8)

local function fireStep()
    if not stepEvent then stepEvent = RS:FindFirstChild("StepEvent") end
    if stepEvent then stepEvent:FireServer() end
end

local function stopFarm()
    farmActive = false
    if farmConnection then farmConnection:Disconnect() farmConnection = nil end
    if lagConnection then lagConnection:Disconnect() lagConnection = nil end
    LagWarning.Text = ""
    StatusLabel.Text = "Status: Idle"
    StatusLabel.TextColor3 = Color3.fromRGB(120, 120, 140)
    TweenService:Create(ToggleBtn, TweenInfo.new(0.2), {BackgroundColor3 = Color3.fromRGB(80, 60, 200)}):Play()
    ToggleBtn.Text = "Start Farming"
end

local function startFarm()
    farmActive = true

    local lastTime = tick()
    lagConnection = RunService.Heartbeat:Connect(function()
        local now = tick()
        if now - lastTime > 0.05 then
            LagWarning.Text = "⚠ Lag detected"
        else
            LagWarning.Text = ""
        end
        lastTime = now
    end)

    if currentMode == "safe" then

        farmConnection = RunService.Heartbeat:Connect(function()
            if not farmActive then return end
            fireStep()
            fireStep()
            fireStep()
        end)
        LagWarning.Text = ""
    else

        farmConnection = RunService.Heartbeat:Connect(function()
            if not farmActive then return end
            for _ = 1, 20 do fireStep() end
        end)
        LagWarning.Text = "⚠ Lag + Audio leak expected"
        LagWarning.TextColor3 = Color3.fromRGB(255, 140, 0)
    end

    StatusLabel.Text = "Status: Farming"
    StatusLabel.TextColor3 = Color3.fromRGB(120, 255, 160)
    TweenService:Create(ToggleBtn, TweenInfo.new(0.2), {BackgroundColor3 = Color3.fromRGB(40, 160, 90)}):Play()
    ToggleBtn.Text = "Stop Farming"
end

local function setMode(mode)
    currentMode = mode
    if mode == "safe" then
        TweenService:Create(SafeBtn, TweenInfo.new(0.15), {BackgroundColor3 = Color3.fromRGB(80, 60, 200)}):Play()
        SafeBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
        TweenService:Create(FastBtn, TweenInfo.new(0.15), {BackgroundColor3 = Color3.fromRGB(40, 40, 55)}):Play()
        FastBtn.TextColor3 = Color3.fromRGB(180, 180, 180)
    else
        TweenService:Create(FastBtn, TweenInfo.new(0.15), {BackgroundColor3 = Color3.fromRGB(200, 80, 40)}):Play()
        FastBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
        TweenService:Create(SafeBtn, TweenInfo.new(0.15), {BackgroundColor3 = Color3.fromRGB(40, 40, 55)}):Play()
        SafeBtn.TextColor3 = Color3.fromRGB(180, 180, 180)
    end
    if farmActive then stopFarm() startFarm() end
end

SafeBtn.MouseButton1Click:Connect(function() setMode("safe") end)
FastBtn.MouseButton1Click:Connect(function() setMode("fast") end)

ToggleBtn.MouseButton1Click:Connect(function()
    if farmActive then stopFarm() else startFarm() end
end)

ToggleBtn.MouseEnter:Connect(function()
    if not farmActive then
        TweenService:Create(ToggleBtn, TweenInfo.new(0.15), {BackgroundColor3 = Color3.fromRGB(100, 80, 220)}):Play()
    end
end)

ToggleBtn.MouseLeave:Connect(function()
    if not farmActive then
        TweenService:Create(ToggleBtn, TweenInfo.new(0.15), {BackgroundColor3 = Color3.fromRGB(80, 60, 200)}):Play()
    end
end)

Player.CharacterRemoving:Connect(stopFarm)

Features & Information

Slow and fast autofarm WARNING THE FAST AUTOFARM WILL MOST LIKELY MAKE YOUR COMPUTORS AUDIO VERY HIGH AND SOMTIMES LAG THE GAME!
#autofarm#op

Community Comments (0)

No comments yet for this script.

More Scripts for [WORLD 4!] 1 Plank = $1/s