OP hub tween script
Key Required

OP hub tween script

Build A Boat For TreasureHEJHEJBANANHEJHEJBANAN 1.5K views 70 executesUpdated Dec 18, 2025
Unrated
00
Lua Script•117 lines (3137 chars)
-- Build A Boat Autofarm (Delta / LocalScript)

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")

local player = Players.LocalPlayer
local autofarm = false
local busy = false

-- ================= GUI =================
local gui = Instance.new("ScreenGui")
gui.Name = "BAB_Autofarm"
gui.ResetOnSpawn = false
gui.Parent = player.PlayerGui

local frame = Instance.new("Frame", gui)
frame.Size = UDim2.new(0, 220, 0, 120)
frame.Position = UDim2.new(0.5, -110, 0.6, 0)
frame.BackgroundColor3 = Color3.fromRGB(25,25,25)
frame.Active = true
frame.Draggable = true

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

local btn = Instance.new("TextButton", frame)
btn.Size = UDim2.new(0.85, 0, 0.45, 0)
btn.Position = UDim2.new(0.075, 0, 0.3, 0)
btn.Text = "Autofarm: OFF"
btn.TextScaled = true
btn.BackgroundColor3 = Color3.fromRGB(170,50,50)
btn.TextColor3 = Color3.new(1,1,1)
Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 10)

-- ================= FUNCTIONS =================

local function getHRP()
    local char = player.Character or player.CharacterAdded:Wait()
    return char:WaitForChild("HumanoidRootPart")
end

local function getChestPart()
    local chest = workspace:FindFirstChild("goldenchest")
    if not chest then return nil end

    if chest:IsA("Model") then
        return chest.PrimaryPart or chest:FindFirstChildWhichIsA("BasePart", true)
    elseif chest:IsA("BasePart") then
        return chest
    end

    return nil
end

local function tweenTo(cframe, speed)
    local hrp = getHRP()
    local distance = (hrp.Position - cframe.Position).Magnitude
    local time = distance / speed

    local tween = TweenService:Create(
        hrp,
        TweenInfo.new(time, Enum.EasingStyle.Linear),
        {CFrame = cframe}
    )
    tween:Play()
    tween.Completed:Wait()
end

local function startAutofarm()
    if busy then return end
    busy = true

    task.spawn(function()
        while autofarm do
            local hrp = getHRP()
            local chestPart = getChestPart()

            if not chestPart then
                warn("GoldenChest not found or has no parts")
                task.wait(1)
                continue
            end

            -- Go up 20 studs
            tweenTo(hrp.CFrame + Vector3.new(0, 20, 0), 1000)

            -- Go above chest
            tweenTo(chestPart.CFrame + Vector3.new(0, 20, 0), 1000)

            -- Go down onto chest
            tweenTo(chestPart.CFrame + Vector3.new(0, 2, 0), 600)

            task.wait(0.5)
        end
        busy = false
    end)
end

-- ================= BUTTON =================
btn.MouseButton1Click:Connect(function()
    autofarm = not autofarm
    if autofarm then
        btn.Text = "Autofarm: ON"
        btn.BackgroundColor3 = Color3.fromRGB(60,180,75)
        startAutofarm()
    else
        btn.Text = "Autofarm: OFF"
        btn.BackgroundColor3 = Color3.fromRGB(170,50,50)
    end
end)

-- ================= RESPAWN =================
player.CharacterAdded:Connect(function()
    if autofarm then
        task.wait(1)
        startAutofarm()
    end
end)

Features & Information

THis hub has autofarm gold so you tween to the end and reset getting infinite gold

Community Comments (1)

luca2000gteluca2000gteDec 22, 2025

doesnt work

More Scripts for Build A Boat For Treasure