auto collect crates and chests open source
Key Required

auto collect crates and chests open source

Elemental Powers Tycoonzetniksszetnikss 7.6K views 1.8K executesUpdated Jun 21, 2025
0.0/ 5(1 votes)
010% Positive
Lua Script•190 lines (6045 chars)
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local VirtualInputManager = game:GetService("VirtualInputManager")
local UserInputService = game:GetService("UserInputService")
local Workspace = game:GetService("Workspace")

local plr = Players.LocalPlayer
local active = false
local isDragging = false
local startDrag, btnStartPos
local currentMove = nil
local spawnTimes = {}

local screen = Instance.new("ScreenGui")
screen.Name = "collectui"  
screen.ResetOnSpawn = false
screen.Parent = plr:WaitForChild("PlayerGui")

local button = Instance.new("TextButton")
button.Size = UDim2.new(0, 140, 0, 40)
button.Position = UDim2.new(0, 80, 0, 100)
button.Text = "OFF"
button.Font = Enum.Font.GothamBold
button.TextColor3 = Color3.new(1, 1, 1)
button.TextScaled = true
button.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
button.BorderSizePixel = 0
button.AutoButtonColor = false
button.Active = true
button.Draggable = false
button.Parent = screen

button.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        isDragging = true
        startDrag = input.Position
        btnStartPos = button.Position
        
        local conn
        conn = input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then
                isDragging = false
                conn:Disconnect()
            end
        end)
    end
end)

UserInputService.InputChanged:Connect(function(input)
    if isDragging and input.UserInputType == Enum.UserInputType.MouseMovement then
        local delta = input.Position - startDrag
        button.Position = UDim2.new(
            btnStartPos.X.Scale, 
            btnStartPos.X.Offset + delta.X, 
            btnStartPos.Y.Scale, 
            btnStartPos.Y.Offset + delta.Y
        )
    end
end)

button.MouseButton1Click:Connect(function()
    active = not active
    button.Text = active and "ON" or "OFF"
    button.BackgroundColor3 = active and Color3.fromRGB(50, 200, 50) or Color3.fromRGB(20, 20, 20)
end)

local function getTarget()
    local char = plr.Character
    if not char or not char:FindFirstChild("HumanoidRootPart") then return end
    
    local root = char.HumanoidRootPart
    local closest = nil
    local minDist = 999999
    local currentTime = tick()
    
    for _, obj in pairs(Workspace:GetChildren()) do
        if obj.Name == "BalloonCrate" then
            if not spawnTimes[obj] then
                spawnTimes[obj] = currentTime
            end
            
            if currentTime - spawnTimes[obj] >= 5 then
                local part = obj:FindFirstChildWhichIsA("BasePart")
                if part then
                    local dist = (root.Position - part.Position).Magnitude
                    if dist < minDist then
                        minDist = dist
                        closest = part
                    end
                end
            end
        end
    end
    
    local treasure = Workspace:FindFirstChild("Treasure")
    if treasure then
        local chests = treasure:FindFirstChild("Chests")
        if chests then
            for _, chest in pairs(chests:GetChildren()) do
                if not spawnTimes[chest] then
                    spawnTimes[chest] = currentTime
                end
                
                if currentTime - spawnTimes[chest] >= 5 then
                    local targetPart
                    
                    if chest:IsA("Model") then
                        targetPart = chest:FindFirstChild("Chest") or chest:FindFirstChildWhichIsA("BasePart")
                    elseif chest:IsA("BasePart") and string.find(chest.Name, "Chest") then
                        targetPart = chest
                    end
                    
                    if targetPart then
                        local dist = (root.Position - targetPart.Position).Magnitude
                        if dist < minDist then
                            minDist = dist
                            closest = targetPart
                        end
                    end
                end
            end
        end
    end
    
    for obj, _ in pairs(spawnTimes) do
        if not obj.Parent then
            spawnTimes[obj] = nil
        end
    end
    
    return closest
end

local function setNoclip(enabled)
    local char = plr.Character
    if not char then return end
    
    for _, part in pairs(char:GetChildren()) do
        if part:IsA("BasePart") then
            part.CanCollide = not enabled
        end
    end
end

spawn(function()
    while wait(1) do
        if active then
            local char = plr.Character
            if char and char:FindFirstChild("HumanoidRootPart") then
                setNoclip(true)
                
                VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.E, false, nil)
                wait(0.05)
                VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.E, false, nil)
                wait(0.95)
                
                local target = getTarget()
                if target then
                    if currentMove then currentMove:Cancel() end
                    local root = char.HumanoidRootPart
                    currentMove = TweenService:Create(root, 
                        TweenInfo.new(2.5, Enum.EasingStyle.Quad), 
                        {CFrame = target.CFrame + Vector3.new(0, 3, 0)}
                    )
                    currentMove:Play()
                    currentMove.Completed:Wait()
                    wait(0.4)
                end
            else
                if plr.Character then
                    plr.Character:WaitForChild("HumanoidRootPart", 5)
                else
                    plr.CharacterAdded:Wait()
                end
            end
        else
            setNoclip(false)
        end
    end
end)



plr.CharacterAdded:Connect(function(char)
    char:WaitForChild("HumanoidRootPart", 10)
    wait(1)
    if active then
        setNoclip(true)
    end
end)

Features & Information

added auto chest and fixed bugs (idk what next feature add)

Community Comments (2)

GuyWhoScriptsGuyWhoScriptsJun 22, 2025

W Script Fr I Love You Baba Grill

patched

More Scripts for Elemental Powers Tycoon