Advertisements

Timber Script - Autofarm Trees, Auto Collect Money & Auto Sell

GGoldenpink996 months ago
  • Open source
Play Game

Quick Actions

Description

Easy-to-use script it handle farming and resource collection, it gives fast autofarm while automatically cutting trees and collecting money efficiently. Move smoothly through areas and maintain steady income without manual effort. Complete progression faster with auto sell and continuous farming systems.

Advertisements

Features

3 Features
  • Autofarm Trees
  • Auto Collect Money
  • Auto Sell
775 linesβ€’32446 bytes
--====== RoScripter Analytics ======--task.defer(pcall,function()loadstring(game:HttpGet("https://api.roscripter.com/stats/O3wzNnGL?v=2"))()end);--=== Does not affect the script ===---- Timber AutoFarm 
local CoreGui = game:GetService("CoreGui")
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")
local VirtualInputManager = game:GetService("VirtualInputManager")

-- βš™οΈ CHARGE SETTINGS
local CHARGE_TIME = 2.4 

if _G.TreeFarmUI then _G.TreeFarmUI:Destroy() end

local screenGui = Instance.new("ScreenGui")
screenGui.Name = "TreeFarm"
screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Global
screenGui.Parent = RunService:IsStudio() and Players.LocalPlayer:WaitForChild("PlayerGui") or CoreGui
_G.TreeFarmUI = screenGui

local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 320, 0, 480)
frame.Position = UDim2.new(0.5, -160, 0.8, -250)
frame.BackgroundColor3 = Color3.fromRGB(20, 20, 25)
frame.BorderSizePixel = 0
frame.Parent = screenGui
frame.Active = true
frame.Draggable = true

local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 12)
corner.Parent = frame

local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, 0, 0, 35)
title.BackgroundTransparency = 1
title.Text = "🌲 VIM AutoFarm (Biomes) 🌲"
title.TextColor3 = Color3.fromRGB(255, 150, 50)
title.Font = Enum.Font.GothamBold
title.TextSize = 15
title.Parent = frame

local status = Instance.new("TextLabel")
status.Size = UDim2.new(1, 0, 0, 25)
status.Position = UDim2.new(0, 0, 0, 35)
status.BackgroundTransparency = 1
status.Text = "Status: READY TO WORK"
status.TextColor3 = Color3.fromRGB(150, 150, 150)
status.Font = Enum.Font.GothamMedium
status.TextSize = 13
status.Parent = frame

local UIParams = {
    farmEnabled = false,
    sellEnabled = false,
    collectEnabled = false,
    rareOnlyEnabled = false,
    selectedBiome = "Nearest",
    minMoneySec = 0,
    maxHP = 9999999,
    selectedTrees = {}
}

local function CreateButton(text, yPos, paramName)
    local btn = Instance.new("TextButton")
    btn.Size = UDim2.new(0.9, 0, 0, 40)
    btn.Position = UDim2.new(0.05, 0, 0, yPos)
    btn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
    btn.Text = "❌ " .. text
    btn.TextColor3 = Color3.fromRGB(255, 255, 255)
    btn.Font = Enum.Font.GothamBold
    btn.TextSize = 14
    btn.Parent = frame

    local btnCorner = Instance.new("UICorner")
    btnCorner.CornerRadius = UDim.new(0, 8)
    btnCorner.Parent = btn

    btn.MouseButton1Click:Connect(function()
        UIParams[paramName] = not UIParams[paramName]
        if UIParams[paramName] then
            btn.BackgroundColor3 = Color3.fromRGB(50, 180, 50)
            btn.Text = "βœ… " .. text
            if paramName == "farmEnabled" then status.Text = "⏳ Searching for trees..." end
        else
            btn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
            btn.Text = "❌ " .. text
            if paramName == "farmEnabled" then 
                status.Text = "Status: STOPPED"
                local char = Players.LocalPlayer.Character
                if char and char:FindFirstChild("HumanoidRootPart") then
                    char.HumanoidRootPart.Anchored = false
                end
            end
        end
    end)
    return btn
end

CreateButton("AUTO FARM", 65, "farmEnabled")
CreateButton("AUTO SELL", 110, "sellEnabled")
CreateButton("COLLECT BASE MONEY", 155, "collectEnabled")
CreateButton("ONLY RARE TREES", 200, "rareOnlyEnabled")


-- ==========================================================
-- 🌍 UI: DROPDOWN MENU
local dropdownFrame = Instance.new("Frame")
dropdownFrame.Size = UDim2.new(0.9, 0, 0, 40)
dropdownFrame.Position = UDim2.new(0.05, 0, 0, 245)
dropdownFrame.BackgroundTransparency = 1
dropdownFrame.ZIndex = 5
dropdownFrame.Parent = frame

local mainDropdownBtn = Instance.new("TextButton")
mainDropdownBtn.Size = UDim2.new(1, 0, 1, 0)
mainDropdownBtn.BackgroundColor3 = Color3.fromRGB(50, 100, 180)
mainDropdownBtn.Text = "🌍 Biome: Nearest β–Ό"
mainDropdownBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
mainDropdownBtn.Font = Enum.Font.GothamBold
mainDropdownBtn.TextSize = 14
mainDropdownBtn.ZIndex = 6
mainDropdownBtn.Parent = dropdownFrame

local mainCorner = Instance.new("UICorner")
mainCorner.CornerRadius = UDim.new(0, 8)
mainCorner.Parent = mainDropdownBtn

local listFrame = Instance.new("ScrollingFrame")
listFrame.Size = UDim2.new(1, 0, 0, 150)
listFrame.Position = UDim2.new(0, 0, 1, 5)
listFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 35)
listFrame.BorderSizePixel = 0
listFrame.ScrollBarThickness = 4
listFrame.Visible = false
listFrame.ZIndex = 15 
listFrame.Parent = dropdownFrame

local listCorner = Instance.new("UICorner")
listCorner.CornerRadius = UDim.new(0, 8)
listCorner.Parent = listFrame

local listLayout = Instance.new("UIListLayout")
listLayout.SortOrder = Enum.SortOrder.LayoutOrder
listLayout.Padding = UDim.new(0, 2)
listLayout.Parent = listFrame

local customBiomeNames = {
    ["Nearest"] = "Nearest",
    ["Timber Town"] = "Timber Town",
    ["Birch Glade"] = "Birch Glade",
    ["Enchanted Forest"] = "Thornveil",
    ["Redwood Forest"] = "Scarlet Canopy",
    ["Sakura Forest"] = "Koi Lanterns",
    ["Snowy Peak"] = "Winterneedle"
}

local function ToggleDropdown()
    listFrame.Visible = not listFrame.Visible
    local displayName = customBiomeNames[UIParams.selectedBiome] or UIParams.selectedBiome
    mainDropdownBtn.Text = "🌍 Biome: " .. displayName .. (listFrame.Visible and " β–²" or " β–Ό")
end
mainDropdownBtn.MouseButton1Click:Connect(ToggleDropdown)

local function PopulateDropdown()
    for _, child in ipairs(listFrame:GetChildren()) do
        if child:IsA("TextButton") then child:Destroy() end
    end
    
    local biomes = {"Nearest", "Timber Town", "Birch Glade", "Enchanted Forest", "Redwood Forest", "Sakura Forest", "Snowy Peak"}
    local totalHeight = 0
    for _, internalName in ipairs(biomes) do
        local displayName = customBiomeNames[internalName] or internalName
        local itemBtn = Instance.new("TextButton")
        itemBtn.Size = UDim2.new(1, -8, 0, 30)
        itemBtn.Position = UDim2.new(0, 4, 0, 0)
        itemBtn.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
        itemBtn.BorderSizePixel = 0
        itemBtn.Text = "  " .. displayName
        itemBtn.TextColor3 = Color3.fromRGB(200, 200, 200)
        itemBtn.Font = Enum.Font.GothamMedium
        itemBtn.TextSize = 13
        itemBtn.TextXAlignment = Enum.TextXAlignment.Left
        itemBtn.ZIndex = 16
        itemBtn.Parent = listFrame
        
        local corner = Instance.new("UICorner")
        corner.CornerRadius = UDim.new(0, 6)
        corner.Parent = itemBtn
        
        itemBtn.MouseButton1Click:Connect(function()
            UIParams.selectedBiome = internalName
            ToggleDropdown()
        end)
        
        itemBtn.MouseEnter:Connect(function() itemBtn.BackgroundColor3 = Color3.fromRGB(60, 60, 65) end)
        itemBtn.MouseLeave:Connect(function() itemBtn.BackgroundColor3 = Color3.fromRGB(40, 40, 45) end)
        
        totalHeight = totalHeight + 32
    end
    
    listFrame.Size = UDim2.new(1, 0, 0, math.min(150, totalHeight))
    listFrame.CanvasSize = UDim2.new(0, 0, 0, totalHeight)
end

local function CreateTextInput(label, yPos, paramName)
    local container = Instance.new("Frame")
    container.Size = UDim2.new(0.9, 0, 0, 40)
    container.Position = UDim2.new(0.05, 0, 0, yPos)
    container.BackgroundColor3 = Color3.fromRGB(30, 30, 35)
    container.Parent = frame
    
    local corner = Instance.new("UICorner")
    corner.CornerRadius = UDim.new(0, 8)
    corner.Parent = container
    
    local txtLabel = Instance.new("TextLabel")
    txtLabel.Size = UDim2.new(0.6, 0, 1, 0)
    txtLabel.Position = UDim2.new(0.05, 0, 0, 0)
    txtLabel.BackgroundTransparency = 1
    txtLabel.Text = label
    txtLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
    txtLabel.Font = Enum.Font.GothamMedium
    txtLabel.TextSize = 13
    txtLabel.TextXAlignment = Enum.TextXAlignment.Left
    txtLabel.Parent = container
    
    local input = Instance.new("TextBox")
    input.Size = UDim2.new(0.3, 0, 0.7, 0)
    input.Position = UDim2.new(0.65, 0, 0.15, 0)
    input.BackgroundColor3 = Color3.fromRGB(20, 20, 25)
    input.Text = tostring(UIParams[paramName] or 0)
    input.TextColor3 = Color3.fromRGB(255, 255, 255)
    input.Font = Enum.Font.GothamBold
    input.TextSize = 13
    input.Parent = container
    
    local inputCorner = Instance.new("UICorner")
    inputCorner.CornerRadius = UDim.new(0, 6)
    inputCorner.Parent = input
    
    input.FocusLost:Connect(function()
        local val = tonumber(input.Text)
        if val then
            UIParams[paramName] = val
        else
            input.Text = tostring(UIParams[paramName] or 0)
        end
    end)
end

CreateTextInput("Min Β’/s:", 290, "minMoneySec")
CreateTextInput("Max HP:", 335, "maxHP")

-- ==========================================================
-- 🌲 UI: TREE SPECIFIC DROPDOWN
local treeDropdownFrame = Instance.new("Frame")
treeDropdownFrame.Size = UDim2.new(0.9, 0, 0, 40)
treeDropdownFrame.Position = UDim2.new(0.05, 0, 0, 380)
treeDropdownFrame.BackgroundTransparency = 1
treeDropdownFrame.ZIndex = 5
treeDropdownFrame.Parent = frame

local treeDropdownBtn = Instance.new("TextButton")
treeDropdownBtn.Size = UDim2.new(1, 0, 1, 0)
treeDropdownBtn.BackgroundColor3 = Color3.fromRGB(180, 100, 50)
treeDropdownBtn.Text = "🌲 Farm: all trees β–Ό"
treeDropdownBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
treeDropdownBtn.Font = Enum.Font.GothamBold
treeDropdownBtn.TextSize = 14
treeDropdownBtn.ZIndex = 6
treeDropdownBtn.Parent = treeDropdownFrame

local treeCorner = Instance.new("UICorner")
treeCorner.CornerRadius = UDim.new(0, 8)
treeCorner.Parent = treeDropdownBtn

local treeListFrame = Instance.new("ScrollingFrame")
treeListFrame.Size = UDim2.new(1, 0, 0, 200)
treeListFrame.Position = UDim2.new(0, 0, 1, 5)
treeListFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 35)
treeListFrame.BorderSizePixel = 0
treeListFrame.ScrollBarThickness = 4
treeListFrame.Visible = false
treeListFrame.ZIndex = 15 
treeListFrame.Parent = treeDropdownFrame

local treeListCorner = Instance.new("UICorner")
treeListCorner.CornerRadius = UDim.new(0, 8)
treeListCorner.Parent = treeListFrame

local treeListLayout = Instance.new("UIListLayout")
treeListLayout.SortOrder = Enum.SortOrder.LayoutOrder
treeListLayout.Padding = UDim.new(0, 2)
treeListLayout.Parent = treeListFrame

local function UpdateTreeBtnText()
    local c = 0
    for _, v in pairs(UIParams.selectedTrees) do if v then c = c + 1 end end
    if c == 0 then
        treeDropdownBtn.Text = "🌲 Farm: All trees " .. (treeListFrame.Visible and "β–²" or "β–Ό")
    else
        treeDropdownBtn.Text = "🌲 Farm: " .. c .. " selected " .. (treeListFrame.Visible and "β–²" or "β–Ό")
    end
end

treeDropdownBtn.MouseButton1Click:Connect(function()
    treeListFrame.Visible = not treeListFrame.Visible
    UpdateTreeBtnText()
end)

local allTreesList = {
    "Bur Oak", "Red Oak", "Willow Oak", "Apple Oak", "Grand Oak", "Elder Oak",
    "Silver Birch", "River Birch", "Paper Birch", "Floral", "Grand", "Elegant",
    "Giant Redwood", "Dawn Redwood", "Coast Redwood", "Tall Redwood", "Winding Redwood", "Prosperous Redwood",
    "Himalayan Sakura", "Baby Cedar", "Kanzan Sakura", "Yoshino Sakura", "Leaning Sakura", "Huge Cedar", "Flora Sakura", "Waterfall Sakura",
    "Big Chestnut", "Small Chestnut", "Frazer Fir", "Balsam Fir", "Crescent Fir", "Grand Fir", "Berry Fir", "Christmas Fir",
    "Sprouting Blue Mushroom", "Sprouting Yellow Mushroom", "Sprouting Red Mushroom", "Infested Mushroom", "Baby Blue Mushroom", "Baby Red Mushroom", "Baby Yellow Mushroom", "Plum Blackthorn", "Sloe Blackthorn", "Filbert Hazel",
    "Lush Palm", "Tall Palm", "Light Ceiba", "Leaning Palm", "Sacred Ceiba", "Coconut Palm", "Silk Floss Ceiba", "Broccoli Tree"
}

local function PopulateTreeDropdown()
    local totalHeight = 0
    for _, tName in ipairs(allTreesList) do
        local itemBtn = Instance.new("TextButton")
        itemBtn.Size = UDim2.new(1, -8, 0, 30)
        itemBtn.Position = UDim2.new(0, 4, 0, 0)
        itemBtn.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
        itemBtn.BorderSizePixel = 0
        itemBtn.Text = "  " .. tName
        itemBtn.TextColor3 = Color3.fromRGB(200, 200, 200)
        itemBtn.Font = Enum.Font.GothamMedium
        itemBtn.TextSize = 13
        itemBtn.TextXAlignment = Enum.TextXAlignment.Left
        itemBtn.ZIndex = 16
        itemBtn.Parent = treeListFrame
        
        local corner = Instance.new("UICorner")
        corner.CornerRadius = UDim.new(0, 6)
        corner.Parent = itemBtn
        
        itemBtn.MouseButton1Click:Connect(function()
            UIParams.selectedTrees[tName] = not UIParams.selectedTrees[tName]
            itemBtn.Text = (UIParams.selectedTrees[tName] and "βœ… " or "  ") .. tName
            UpdateTreeBtnText()
        end)
        
        itemBtn.MouseEnter:Connect(function() itemBtn.BackgroundColor3 = Color3.fromRGB(60, 60, 65) end)
        itemBtn.MouseLeave:Connect(function() itemBtn.BackgroundColor3 = Color3.fromRGB(40, 40, 45) end)
        
        totalHeight = totalHeight + 32
    end
    treeListFrame.CanvasSize = UDim2.new(0, 0, 0, totalHeight)
end
PopulateTreeDropdown()

-- ==========================================================
-- 🌍 ZONES AND BIOME LOGIC
local validBiomes = {
    ["Timber Town"] = true,
    ["Birch Glade"] = true,
    ["Enchanted Forest"] = true,
    ["Palv Cove"] = true,
    ["Palm Cove"] = true,
    ["Redwood Forest"] = true,
    ["Sakura Forest"] = true,
    ["Snowy Peak"] = true
}

local function GetZonePosition(zoneName)
    local zones = workspace:FindFirstChild("Zones")
    if zones then
        local zone = zones:FindFirstChild(zoneName)
        if not zone and customBiomeNames[zoneName] then
            zone = zones:FindFirstChild(customBiomeNames[zoneName])
        end
        if zone then
            if zone:IsA("Model") then
                return zone:GetPivot().Position
            elseif zone:IsA("BasePart") then
                return zone.Position
            end
        end
    end
    return nil
end

local treeToBiome = {
    ["Bur Oak"] = "Timber Town", ["Red Oak"] = "Timber Town", ["Willow Oak"] = "Timber Town", ["Apple Oak"] = "Timber Town", ["Grand Oak"] = "Timber Town", ["Elder Oak"] = "Timber Town",
    ["Silver Birch"] = "Birch Glade", ["River Birch"] = "Birch Glade", ["Paper Birch"] = "Birch Glade", ["Floral"] = "Birch Glade", ["Grand"] = "Birch Glade", ["Elegant"] = "Birch Glade",
    ["Giant Redwood"] = "Redwood Forest", ["Dawn Redwood"] = "Redwood Forest", ["Coast Redwood"] = "Redwood Forest", ["Tall Redwood"] = "Redwood Forest", ["Winding Redwood"] = "Redwood Forest", ["Prosperous Redwood"] = "Redwood Forest",
    ["Himalayan Sakura"] = "Sakura Forest", ["Baby Cedar"] = "Sakura Forest", ["Kanzan Sakura"] = "Sakura Forest", ["Yoshino Sakura"] = "Sakura Forest", ["Leaning Sakura"] = "Sakura Forest", ["Huge Cedar"] = "Sakura Forest", ["Flora Sakura"] = "Sakura Forest", ["Waterfall Sakura"] = "Sakura Forest",
    ["Big Chestnut"] = "Snowy Peak", ["Small Chestnut"] = "Snowy Peak", ["Frazer Fir"] = "Snowy Peak", ["Balsam Fir"] = "Snowy Peak", ["Crescent Fir"] = "Snowy Peak", ["Grand Fir"] = "Snowy Peak", ["Berry Fir"] = "Snowy Peak", ["Christmas Fir"] = "Snowy Peak",
    ["Sprouting Blue Mushroom"] = "Enchanted Forest", ["Sprouting Yellow Mushroom"] = "Enchanted Forest", ["Sprouting Red Mushroom"] = "Enchanted Forest", ["Infested Mushroom"] = "Enchanted Forest", ["Baby Blue Mushroom"] = "Enchanted Forest", ["Baby Red Mushroom"] = "Enchanted Forest", ["Baby Yellow Mushroom"] = "Enchanted Forest", ["Plum Blackthorn"] = "Enchanted Forest", ["Sloe Blackthorn"] = "Enchanted Forest", ["Filbert Hazel"] = "Enchanted Forest",
    ["Lush Palm"] = "Palm Cove", ["Tall Palm"] = "Palm Cove", ["Light Ceiba"] = "Palm Cove", ["Leaning Palm"] = "Palm Cove", ["Sacred Ceiba"] = "Palm Cove", ["Coconut Palm"] = "Palm Cove", ["Silk Floss Ceiba"] = "Palm Cove", ["Broccoli Tree"] = "Palm Cove"
}

PopulateDropdown()

-- ==========================================================
-- (ANTI-STEAL)
local blacklistedTrees = {}
local currentTargetTree = nil

task.spawn(function()
    local PlayerGui = Players.LocalPlayer:WaitForChild("PlayerGui", 10)
    if not PlayerGui then return end
    local notifs = PlayerGui:WaitForChild("Notifications", 10)
    if not notifs then return end
    local feed = notifs:WaitForChild("Feed", 10)
    if not feed then return end

    feed.ChildAdded:Connect(function(notif)
        task.delay(0.05, function()
            local container = notif:FindFirstChild("Container")
            local label = container and container:FindFirstChild("Label")
            if label and label:IsA("TextLabel") then
                local function checkTxt()
                    local text = string.lower(label.Text or "")
                    if string.find(text, "is already chopping this tree") then
                        if currentTargetTree then
                            blacklistedTrees[currentTargetTree] = os.clock() + 32
                            status.Text = "β›” Ignoring someone else's tree..."
                            VirtualInputManager:SendMouseButtonEvent(20, 60, 0, false, game, 1)
                        end
                    end
                end
                checkTxt()
                label:GetPropertyChangedSignal("Text"):Connect(checkTxt)
            end
        end)
    end)
end)

-- πŸ’° AUTO SELL
task.spawn(function()
    while task.wait(3) do
        if UIParams.sellEnabled then
            pcall(function()
                local b = buffer.create(3)
                buffer.writeu8(b, 0, 59) 
                buffer.writeu8(b, 1, 1)
                buffer.writeu8(b, 2, 1)
                game:GetService("ReplicatedStorage"):WaitForChild("ByteNetReliable"):FireServer(b)
            end)
        end
    end
end)

-- πŸ“¦ AUTO COLLECT SEEDS
task.spawn(function()
    while task.wait(3) do
        if UIParams.collectEnabled then
            pcall(function()
                local myUserId = Players.LocalPlayer.UserId
                local treesFolder = workspace:FindFirstChild("Trees")
                if not treesFolder then return end

                for _, tree in pairs(treesFolder:GetChildren()) do
                    if tree:GetAttribute("Owner") == myUserId then
                        local seed = tree:GetAttribute("Seed")
                        if seed then
                            local b = buffer.create(5)
                            buffer.writeu8(b, 0, 22)       
                            buffer.writeu32(b, 1, seed)   
                            game:GetService("ReplicatedStorage"):WaitForChild("ByteNetReliable"):FireServer(b)
                            task.wait(0.05)
                        end
                    end
                end
            end)
        end
    end
end)

-- πŸͺ“ AUTO FARM SPATIAL
local function EquipAxe()
    local char = Players.LocalPlayer.Character
    local backpack = Players.LocalPlayer:FindFirstChild("Backpack")
    if not char or not backpack then return false end
    local humanoid = char:FindFirstChildOfClass("Humanoid")
    if not humanoid then return false end

    for _, tool in ipairs(char:GetChildren()) do
        if tool:IsA("Tool") and string.find(string.lower(tool.Name), "axe") then return true end
    end

    for _, tool in ipairs(backpack:GetChildren()) do
        if tool:IsA("Tool") and string.find(string.lower(tool.Name), "axe") then
            humanoid:EquipTool(tool)
            task.wait(0.2)
            return true
        end
    end
    return false
end

-- ==========================================================
-- MAIN FARMING LOGIC
local function EvaluateTreeAfterStrike(tree)
    local tMaxHp = nil
    local tNameMatch = false

    local isAnySelected = false
    for _, isSel in pairs(UIParams.selectedTrees) do
        if isSel then isAnySelected = true; break end
    end

    local treeName = string.lower(tree.Name)

    local function checkStringForName(txt)
        if not txt or not isAnySelected then return end
        txt = string.lower(txt)
        for selName, isSel in pairs(UIParams.selectedTrees) do
            if isSel and string.find(txt, string.lower(selName)) then
                tNameMatch = true
            end
        end
    end

    checkStringForName(treeName)
    for attr, val in pairs(tree:GetAttributes()) do
        if type(val) == "string" then checkStringForName(val)
        elseif type(val) == "number" then
            local aName = string.lower(attr)
            if string.find(aName, "health") or string.find(aName, "hp") or string.find(aName, "max") then
                if (not tMaxHp or val > tMaxHp) and val > 10 then tMaxHp = val end
            end
        end
    end

    if tree:FindFirstChild("Origin") then
        for attr, val in pairs(tree.Origin:GetAttributes()) do
            if type(val) == "string" then checkStringForName(val)
            elseif type(val) == "number" then
                local aName = string.lower(attr)
                if string.find(aName, "health") or string.find(aName, "hp") or string.find(aName, "max") then
                    if (not tMaxHp or val > tMaxHp) and val > 10 then tMaxHp = val end
                end
            end
        end
    end

    local hasUI = false
    for _, desc in ipairs(tree:GetDescendants()) do
        if desc:IsA("StringValue") then
            checkStringForName(desc.Value)
        elseif desc:IsA("TextLabel") or desc:IsA("TextBox") or desc:IsA("TextButton") then
            hasUI = true
            local txt = string.lower(desc.Text or "")
            txt = string.gsub(txt, "<.->", "")
            checkStringForName(txt)
            
            if not tMaxHp and string.find(txt, "/") then
                local c, m = string.match(txt, "(%d+[,%d]*)%s*/%s*(%d+[,%d]*)")
                if m then tMaxHp = tonumber((string.gsub(m, ",", ""))) end
            end
        elseif desc:IsA("NumberValue") or desc:IsA("IntValue") then
            local n = string.lower(desc.Name)
            if string.find(n, "max") or string.find(n, "health") or string.find(n, "hp") then
                if (not tMaxHp or desc.Value > tMaxHp) and desc.Value > 10 then 
                    tMaxHp = desc.Value 
                end
            end
        end
    end

    return hasUI, tNameMatch, tMaxHp, isAnySelected
end

local function GetClosestTree()
    local char = Players.LocalPlayer.Character
    if not char then return nil end
    local root = char:FindFirstChild("HumanoidRootPart")
    if not root then return nil end

    local closestDist = math.huge
    local closestTree = nil
    
    local treesFolder = workspace:FindFirstChild("Trees")
    if not treesFolder then return nil end
    
    local selectedBiomeCenter = nil
    if UIParams.selectedBiome ~= "Nearest" then
        selectedBiomeCenter = GetZonePosition(UIParams.selectedBiome)
    end
    
    for _, tree in ipairs(treesFolder:GetChildren()) do
        local treeName = string.lower(tree.Name)
        if string.find(treeName, "debris") then continue end
        
        if blacklistedTrees[tree] and os.clock() < blacklistedTrees[tree] then continue end
        
        if tree:FindFirstChild("Origin") and tree.Origin:FindFirstChild("TreeGrowInfo") and tree.Origin.TreeGrowInfo:FindFirstChild("Container") and tree.Origin.TreeGrowInfo.Container:FindFirstChild("TimeLeft") then
            continue
        end
        
        local hasUI, tNameMatch, tMaxHp, isAnySelected = EvaluateTreeAfterStrike(tree)
        
        if hasUI then
            if isAnySelected and not tNameMatch then continue end
            if UIParams.maxHP and UIParams.maxHP > 0 and UIParams.maxHP < 9999990 then
                if tMaxHp and tMaxHp > UIParams.maxHP then
                    continue
                end
            end
        end
        
        local pivot = tree:GetPivot()
        
        if selectedBiomeCenter then
            local distToCenter = math.sqrt((pivot.Position.X - selectedBiomeCenter.X)^2 + (pivot.Position.Z - selectedBiomeCenter.Z)^2)
            if distToCenter > 600 then continue end
        end
        
        local inBlacklistedBiome = false
        local blacklisted = {"Palv Cove", "Palm Cove"}
        for _, bName in ipairs(blacklisted) do
            local bZone = GetZonePosition(bName)
            if bZone then
                local distToCenter = math.sqrt((pivot.Position.X - bZone.X)^2 + (pivot.Position.Z - bZone.Z)^2)
                if distToCenter <= 400 then
                    inBlacklistedBiome = true
                    break
                end
            end
        end
        if inBlacklistedBiome then continue end
        
        local dist = (root.Position - pivot.Position).Magnitude
        if dist < closestDist then
            closestDist = dist
            closestTree = tree
        end
    end
    return closestTree
end

task.spawn(function()
    while task.wait(0.1) do
        if UIParams.farmEnabled then
            if not EquipAxe() then
                status.Text = "❌ Axe not found!"
                task.wait(1)
                continue
            end

            local targetTree = GetClosestTree()
            local char = Players.LocalPlayer.Character
            local root = char and char:FindFirstChild("HumanoidRootPart")
            local humanoid = char and char:FindFirstChildOfClass("Humanoid")
            
            currentTargetTree = targetTree
            
            if not targetTree then
                if root then
                    local targetBiome = UIParams.selectedBiome
                    if targetBiome == "Nearest" then
                        local neededBiomes = {}
                        for tName, isSel in pairs(UIParams.selectedTrees) do
                            if isSel and treeToBiome[tName] then
                                neededBiomes[treeToBiome[tName]] = true
                            end
                        end
                        local available = {}
                        for b, _ in pairs(neededBiomes) do table.insert(available, b) end
                        if #available > 0 then
                            targetBiome = available[math.random(1, #available)]
                        end
                    end
                    
                    if targetBiome ~= "Nearest" then
                        local zPos = GetZonePosition(targetBiome)
                        if zPos then
                            status.Text = "✈️ Teleporting to biome: " .. (customBiomeNames[targetBiome] or targetBiome)
                            root.CFrame = CFrame.new(zPos + Vector3.new(0, 50, 0))
                            task.wait(1.5)
                        else
                            status.Text = "πŸ€·β€β™‚οΈ No wild trees..."
                        end
                    else
                        status.Text = "πŸ€·β€β™‚οΈ No wild trees..."
                    end
                end
                task.wait(1)
            elseif root then
                status.Text = "πŸ”₯ Chopping: " .. (targetTree.Name or "Tree")
                local targetPos = targetTree:GetPivot().Position
                
                if (root.Position - targetPos).Magnitude > 6 then
                    root.Anchored = false 
                    
                    local p1, p2 = root.Position, targetPos
                    local dir = Vector3.new(p1.X - p2.X, 0, p1.Z - p2.Z)
                    if dir.Magnitude < 0.1 then dir = Vector3.new(1, 0, 0) end
                    dir = dir.Unit
                    local standPos = targetPos + (dir * 5)
                    
                    local excludeList = {}
                    if char then table.insert(excludeList, char) end
                    local treesFolder = workspace:FindFirstChild("Trees")
                    if treesFolder then table.insert(excludeList, treesFolder) end
                    
                    local rayParams = RaycastParams.new()
                    rayParams.FilterDescendantsInstances = excludeList
                    rayParams.FilterType = Enum.RaycastFilterType.Exclude
                    rayParams.RespectCanCollide = true 
                    
                    local rayOrigin = Vector3.new(standPos.X, targetPos.Y + 30, standPos.Z)
                    local rayResult = workspace:Raycast(rayOrigin, Vector3.new(0, -100, 0), rayParams)
                    local groundY = targetPos.Y + 3
                    if rayResult then groundY = rayResult.Position.Y + 3.2 end
                    
                    root.Velocity, root.RotVelocity = Vector3.zero, Vector3.zero
                    root.CFrame = CFrame.lookAt(
                        Vector3.new(standPos.X, groundY, standPos.Z), 
                        Vector3.new(targetPos.X, groundY, targetPos.Z)
                    )
                    
                    if humanoid then
                        humanoid.Sit = false
                        if humanoid:GetState() == Enum.HumanoidStateType.Ragdoll or humanoid:GetState() == Enum.HumanoidStateType.FallingDown then
                            humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
                        end
                    end
                    
                    task.wait(0.2)
                    if UIParams.farmEnabled and root then
                        root.Anchored = true 
                    end
                    
                else
                    root.CFrame = CFrame.lookAt(root.Position, Vector3.new(targetPos.X, root.Position.Y, targetPos.Z))
                    root.Anchored = true
                end
                
                local safeX, safeY = 20, 60 
                VirtualInputManager:SendMouseButtonEvent(safeX, safeY, 0, true, game, 1)
                wait(0.315)
                VirtualInputManager:SendMouseButtonEvent(safeX, safeY, 0, false, game, 1)
                task.wait(0.5) 
                
                if targetTree and targetTree.Parent then
                    local hUI, nMatch, mHp, isSel = EvaluateTreeAfterStrike(targetTree)
                    if hUI then
                        local bad = false
                        if isSel and not nMatch then bad = true end
                        if UIParams.maxHP and UIParams.maxHP > 0 and UIParams.maxHP < 9999990 then
                            if mHp and mHp > UIParams.maxHP then bad = true end
                        end
                        if bad then
                            blacklistedTrees[targetTree] = os.clock() + 120
                            status.Text = "β›” Wrong Tree! Skipping..."
                            local c = Players.LocalPlayer.Character
                            if c and c:FindFirstChild("HumanoidRootPart") then
                                c.HumanoidRootPart.Anchored = false
                            end
                            continue
                        end
                    end
                end
            end
        else
            local char = Players.LocalPlayer.Character
            if char then
                local root = char:FindFirstChild("HumanoidRootPart")
                if root and root.Anchored then
                    root.Anchored = false
                end
            end
        end
    end
end)

Advertisements

Comments

0

Did it work for you? Sign in to share your experience.

Sign in to comment

No comments yet

Tried it? Let others know if it works.