Auto farm
Key Required

Auto farm

Rensselaer Countywerewould2werewould2 3.6K views 1.5K executesUpdated Jan 1, 2026
5.0/ 5(1 votes)
10100% Positive
Lua Script•306 lines (11624 chars)
if not game:IsLoaded() then game.Loaded:Wait() end
task.wait(8) -- !!CHANGE THIS IF ITS LOADING TOO SLOW OR TOO FAST!!

local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local GuiService = game:GetService("GuiService")
local CoreGui = game:GetService("CoreGui")
local Workspace = game:GetService("Workspace")
local VirtualUser = game:GetService("VirtualUser")
local LocalPlayer = Players.LocalPlayer

--------------------------------------------------------------------------------
-- ANTI-AFK
--------------------------------------------------------------------------------
LocalPlayer.Idled:Connect(function()
    VirtualUser:CaptureController()
    VirtualUser:ClickButton2(Vector2.new())
end)

--------------------------------------------------------------------------------
-- SAVE SYSTEM
--------------------------------------------------------------------------------
local SAVE_FILE = "XmasFarmData.txt"
local currentBatch = 0

local function SaveProgress()
    writefile(SAVE_FILE, tostring(currentBatch))
end

local function LoadProgress()
    if isfile(SAVE_FILE) then
        local data = readfile(SAVE_FILE)
        local number = tonumber(data)
        if number then
            currentBatch = number
            print("Loaded Batch Count: " .. currentBatch)
        end
    end
end
LoadProgress()

--------------------------------------------------------------------------------
-- BYPASS MENU
--------------------------------------------------------------------------------
local function BypassMainMenu()
    print("STARTING MENU BYPASS...")
    local attempts = 0
    while attempts < 20 do 
        attempts = attempts + 1
        local PlayerGui = LocalPlayer:FindFirstChild("PlayerGui")
        if PlayerGui then
            local menu = PlayerGui:FindFirstChild("MainMenu")
            if menu and menu:FindFirstChild("Holder") then
                local options = menu.Holder:FindFirstChild("MainMenuOptionsHolder")
                if options then
                    local playBtn = options:FindFirstChild("PlayButton")
                    if playBtn and playBtn.Visible then
                        -- Method 1: Direct Signal (Background)
                        pcall(function()
                            for _, connection in pairs(getconnections(playBtn.MouseButton1Click)) do
                                connection:Fire()
                            end
                        end)
                        -- Method 2: Virtual Click (Backup)
                        task.delay(0.1, function()
                             if playBtn and playBtn.Visible then
                                 local pos = playBtn.AbsolutePosition
                                 local size = playBtn.AbsoluteSize
                                 local inset = GuiService:GetGuiInset()
                                 local x = pos.X + (size.X / 2)
                                 local y = pos.Y + (size.Y / 2) + inset.Y
                                 game:GetService("VirtualInputManager"):SendMouseButtonEvent(x, y, 0, true, game, 1)
                                 task.wait(0.05)
                                 game:GetService("VirtualInputManager"):SendMouseButtonEvent(x, y, 0, false, game, 1)
                             end
                        end)
                        task.wait(1)
                    else
                        print("Button gone. Game started.")
                        break
                    end
                end
            else
                print("Menu GUI gone. Farm starting.")
                break
            end
        end
        task.wait(0.7)
    end
end
BypassMainMenu()

--------------------------------------------------------------------------------
-- CONFIGURATION
--------------------------------------------------------------------------------
local isRunning = true
local failedSearchCount = 0
local consecutiveFailures = 0
local MAX_FAILURES = 5

-- TRACKING
local AlreadyFarmed = {}
local TempSkipped = {}

-- SETTINGS
local STAT_NAME = "Cash"
local BATCH_SIZE = 15
local VALID_NAMES = { "Present1", "Present2", "Present3", "Present4", "Present5", "Present6", "Reef", "Stocking" }
local decorFolder = Workspace:WaitForChild("ChristmasDecor", 5)
local foldersToCheck = {}

local function RefreshFolders()
    if decorFolder then
        foldersToCheck = {}
        if decorFolder:FindFirstChild("Presents") then table.insert(foldersToCheck, decorFolder.Presents) end
        if decorFolder:FindFirstChild("Reefs") then table.insert(foldersToCheck, decorFolder.Reefs) end
        if decorFolder:FindFirstChild("Stockings") then table.insert(foldersToCheck, decorFolder.Stockings) end
    end
end
RefreshFolders()

--------------------------------------------------------------------------------
-- HELPER FUNCTIONS
--------------------------------------------------------------------------------
local function GetCurrentCash()
    if LocalPlayer:FindFirstChild("leaderstats") and LocalPlayer.leaderstats:FindFirstChild(STAT_NAME) then
        return LocalPlayer.leaderstats[STAT_NAME].Value
    end
    return 0
end

local function TeleportTo(cframe)
    if LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("HumanoidRootPart") then
        LocalPlayer.Character.HumanoidRootPart.CFrame = cframe
    end
end

--------------------------------------------------------------------------------
-- UI SETUP
--------------------------------------------------------------------------------
local ScreenGui = Instance.new("ScreenGui")
local Frame = Instance.new("Frame")
local Status = Instance.new("TextLabel")
local ToggleBtn = Instance.new("TextButton")

ScreenGui.Name = "OvernightFarmerBg"
if CoreGui:FindFirstChild("OvernightFarmerBg") then CoreGui.OvernightFarmerBg:Destroy() end
ScreenGui.Parent = CoreGui
Frame.Parent = ScreenGui
Frame.BackgroundColor3 = Color3.fromRGB(45, 45, 60)
Frame.Position = UDim2.new(0.1, 0, 0.2, 0)
Frame.Size = UDim2.new(0, 220, 0, 100)
Frame.Active = true; Frame.Draggable = true

Status.Parent = Frame
Status.Size = UDim2.new(1,0,0.5,0)
Status.TextColor3 = Color3.new(1,1,1)
Status.BackgroundTransparency = 1
Status.Text = "Idle"
Status.TextScaled = true

ToggleBtn.Parent = Frame
ToggleBtn.Position = UDim2.new(0,0,0.5,0)
ToggleBtn.Size = UDim2.new(1,0,0.5,0)
ToggleBtn.BackgroundColor3 = Color3.fromRGB(0,100,0)
ToggleBtn.Text = "RUNNING (BG)"
ToggleBtn.TextScaled = true

ToggleBtn.MouseButton1Click:Connect(function()
    isRunning = not isRunning
    ToggleBtn.BackgroundColor3 = isRunning and Color3.fromRGB(0,100,0) or Color3.fromRGB(150,0,0)
    ToggleBtn.Text = isRunning and "RUNNING (BG)" or "STOPPED"
end)

--------------------------------------------------------------------------------
-- CORE LOGIC
--------------------------------------------------------------------------------
local function RejoinServer()
    Status.Text = "Rejoining..."
    task.wait(0.5)
    local QueueOnTeleport = (syn and syn.queue_on_teleport) or queue_on_teleport or (fluxus and fluxus.queue_on_teleport)
    if QueueOnTeleport then
        QueueOnTeleport([[
            repeat task.wait() until game:IsLoaded()
            print("Server hopped successfully")
        ]])
    end
    TeleportService:Teleport(game.PlaceId, LocalPlayer)
end

local function GetClosestItem()
    local char = LocalPlayer.Character
    if not char or not char:FindFirstChild("HumanoidRootPart") then return nil end
    local root = char.HumanoidRootPart
    
    local bestTarget = nil
    local closestDist = 999999
    
    for _, folder in pairs(foldersToCheck) do
        for _, v in pairs(folder:GetChildren()) do
            if AlreadyFarmed[v] then continue end
            if TempSkipped[v] and tick() < TempSkipped[v] then continue end
            
            if table.find(VALID_NAMES, v.Name) then
                local prompt = v:FindFirstChildWhichIsA("ProximityPrompt", true)
                if prompt and prompt.Enabled then
                    local dist = (v:GetPivot().Position - root.Position).Magnitude
                    if dist < closestDist then
                        closestDist = dist
                        bestTarget = v
                    end
                end
            end
        end
    end
    return bestTarget
end

local function AttemptCollect(target)
    local targetPos = target:GetPivot().Position
    local startCash = GetCurrentCash()
    
    for i = 1, 3 do
        if not isRunning then return false end
        Status.Text = "Collect " .. i .. ": " .. target.Name
        
        -- 1. Move to target
        TeleportTo(CFrame.new(targetPos + Vector3.new(0, 4, 0)))
        task.wait(0.2)
        
        -- 2. Interact (Direct Signal - No keys needed)
        local prompt = target:FindFirstChildWhichIsA("ProximityPrompt", true)
        if prompt then 
            prompt.HoldDuration = 0 
            fireproximityprompt(prompt) 
        end
        
        task.wait(0.3)
        
        -- 3. Verify
        local newCash = GetCurrentCash()
        if newCash > startCash then
            return true -- SUCCESS
        end
    end
    return false
end

--------------------------------------------------------------------------------
-- MAIN LOOP
--------------------------------------------------------------------------------
task.spawn(function()
    while true do
        task.wait(0.1)
        if isRunning then
            if not LocalPlayer.Character then 
                task.wait(0.6) 
            else
                if currentBatch >= BATCH_SIZE then
                    Status.Text = "Limit (15) Hit! Rejoining..."
                    currentBatch = 0
                    consecutiveFailures = 0
                    SaveProgress()
                    task.wait(1)
                    RejoinServer()
                else
                    local target = GetClosestItem()
                    if target then
                        failedSearchCount = 0
                        local success = AttemptCollect(target)
                        
                        if success then
                            AlreadyFarmed[target] = true
                            currentBatch = currentBatch + 1
                            consecutiveFailures = 0 
                            SaveProgress()
                            Status.Text = "Cash: ("..currentBatch.."/"..BATCH_SIZE..")"
                        else
                            consecutiveFailures = consecutiveFailures + 1
                            TempSkipped[target] = tick() + 30
                            Status.Text = "Failed ("..consecutiveFailures..")..."
                            
                            if consecutiveFailures >= MAX_FAILURES then
                                Status.Text = "Too many fails! Rejoining..."
                                RejoinServer()
                                break
                            end
                            task.wait(0.5)
                        end
                    else
                        failedSearchCount = failedSearchCount + 1
                        Status.Text = "Searching... ("..failedSearchCount..")"
                        RefreshFolders()
                        
                        if failedSearchCount > 5 then
                            Status.Text = "No items! Rejoining..."
                            RejoinServer()
                            break
                        end
                        task.wait(0.2)
                    end
                end
            end
        end
    end
end)

Features & Information

This an autofarm for the grinches side this was only made for the event and wont work after its over was made by gemini u need to put it in ur autoexec folder too

Community Comments (7)

how to do it?

nvm i got it

werewould2werewould2Jan 5, 2026

made it better leave on for a couple hours for best results

fff312fff312Jan 11, 2026

how do we use it

Replying to @fff312
werewould2werewould2Jan 12, 2026

@fff312 Put it in ur autoexec folder and join rc

fff312fff312Jan 16, 2026

is there any use other than the winter upd

Replying to @fff312
werewould2werewould2Jan 16, 2026

@fff312 Wdym also this script still works im pretty sure

More Scripts for Rensselaer County