AutoFarm Universal
Key RequiredUniversal

AutoFarm Universal

Universal Scriptmpopeesayshimpopeesayshi 4.3K views 488 executesUpdated Feb 15, 2025
Unrated
00
Lua Script•70 lines (2387 chars)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local runService = game:GetService("RunService")

local autoFarm = false
local targetName = ""

-- Create GUI
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = player.PlayerGui

local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 300, 0, 150)
frame.Position = UDim2.new(0.5, -150, 0.2, 0)
frame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
frame.Parent = screenGui

local toggleButton = Instance.new("TextButton")
toggleButton.Size = UDim2.new(0, 280, 0, 50)
toggleButton.Position = UDim2.new(0, 10, 0, 10)
toggleButton.Text = "Start Auto Farm"
toggleButton.BackgroundColor3 = Color3.new(0, 1, 0)
toggleButton.Parent = frame

local inputBox = Instance.new("TextBox")
inputBox.Size = UDim2.new(0, 280, 0, 50)
inputBox.Position = UDim2.new(0, 10, 0, 70)
inputBox.PlaceholderText = "Enter Object Name"
inputBox.Parent = frame

-- Function to find the nearest object by name
local function findClosestObject()
    local closest = nil
    local shortestDistance = math.huge
    for _, obj in pairs(workspace:GetChildren()) do
        if obj:IsA("Part") and string.find(obj.Name:lower(), targetName:lower()) then
            local distance = (humanoidRootPart.Position - obj.Position).Magnitude
            if distance < shortestDistance then
                shortestDistance = distance
                closest = obj
            end
        end
    end
    return closest
end

-- Auto farm loop (smooth movement)
local function autoFarmLoop()
    while autoFarm do
        local target = findClosestObject()
        if target then
            local targetPosition = target.Position - Vector3.new(0, 5, 0) -- Move below object
            humanoidRootPart.CFrame = humanoidRootPart.CFrame:Lerp(CFrame.new(targetPosition), 0.2) -- Smooth movement
        end
        wait(0.1) -- Faster updates for smoother farming
    end
end

-- Toggle button functionality
toggleButton.MouseButton1Click:Connect(function()
    autoFarm = not autoFarm
    toggleButton.Text = autoFarm and "Stop Auto Farm" or "Start Auto Farm"
    toggleButton.BackgroundColor3 = autoFarm and Color3.new(1, 0, 0) or Color3.new(0, 1, 0)
    
    targetName = inputBox.Text
    if autoFarm then
        autoFarmLoop()
    end
end)

Features & Information

This GUI is keyless, Type the name of the item and press AutoFarm Toggle to start farmin!

Community Comments (1)

jjhonson9220jjhonson9220Feb 15, 2025(edited)

do it work with jji?

More Scripts for Universal Scripts