local Library = loadstring(game:HttpGet("https://[Log in to view URL]"))()
local Window = Library.CreateLib("Treasure Hunt Simulator", "Ocean")
local Tab = Window:NewTab("Farming")
local Section = Tab:NewSection("Farming")

local shouldstop = false
local allowrainbowchest = false -- fuck this shit do not work i dont hav e time to edit it eiother fuck of.

-- Global variables for selling
local lastPosition = nil
local isCurrentlySelling = false
local minDepth = 100 -- Minimum depth to mine at
local minReward = 10000 -- Minimum chest value to consider

-- Target specific chest types
local targetSpecificChests = false
local targetChestTypes = {
    ["Snow Chest"] = true,
    ["Magma Chest"] = true,
    ["Knight's Chest"] = true,
    ["Mermaid Chest"] = true
}

-- Enhanced sell function (now sell)
local function performSellX()
    if isCurrentlySelling then return end -- Prevent multiple teleport calls
    
    local player = game:GetService("Players").LocalPlayer
    local character = player.Character
    if not character then return end
    
    local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
    if not humanoidRootPart then return end
    
    -- Store current position
    isCurrentlySelling = true
    lastPosition = humanoidRootPart.CFrame
    
    -- Teleport to sell position
    humanoidRootPart.CFrame = CFrame.new(-243, 10, -281)
    
    -- Wait for sell to process (longer wait for sell)
    wait(0.5)
    
    -- Return to previous position
    if lastPosition then
        humanoidRootPart.CFrame = lastPosition
    end
    
    game.StarterGui:SetCore("SendNotification", {
        Title = "Sell",
        Text = "Items sold successfully!",
        Duration = 2
    })
    
    -- Reset flag
    wait(0.3)
    isCurrentlySelling = false
end

-- Setup chest ESP
local chestESPEnabled = true
local espFolder = Instance.new("Folder")
espFolder.Name = "ChestESP"
espFolder.Parent = game.Workspace

-- Function to create ESP for a chest
local function createChestESP(chest, reward, chestType)
    local esp = Instance.new("BillboardGui")
    esp.Name = "ChestESP"
    esp.AlwaysOnTop = true
    esp.Size = UDim2.new(0, 200, 0, 50)
    esp.StudsOffset = Vector3.new(0, 2, 0)
    esp.Parent = espFolder
    
    local textLabel = Instance.new("TextLabel")
    textLabel.BackgroundTransparency = 1
    textLabel.Size = UDim2.new(1, 0, 1, 0)
    textLabel.Font = Enum.Font.GothamBold
    textLabel.TextColor3 = Color3.fromRGB(255, 255, 0) -- Yellow text
    textLabel.TextStrokeTransparency = 0.5
    textLabel.TextSize = 12
    
    -- Add chest type to ESP if available
    local displayText = "Chest: " .. tostring(reward)
    if chestType and chestType ~= "" then
        displayText = chestType .. ": " .. tostring(reward)
    end
    textLabel.Text = displayText
    
    textLabel.Parent = esp
    
    -- Determine color based on reward value or chest type
    if targetSpecificChests and chestType and targetChestTypes[chestType] then
        textLabel.TextColor3 = Color3.fromRGB(0, 255, 0) -- Green for target chests
    elseif reward >= 1000000 then -- 1M+
        textLabel.TextColor3 = Color3.fromRGB(255, 0, 0) -- Red for high value
    elseif reward >= 100000 then -- 100K+
        textLabel.TextColor3 = Color3.fromRGB(255, 165, 0) -- Orange for medium value
    end
    
    esp.Adornee = chest
    return esp
end

-- Function to check if a position is below a certain depth
local function isDeepEnough(position)
    -- In Treasure Hunt Simulator, the Y coordinate represents depth
    -- Higher negative Y value means deeper
    return position.Y <= -minDepth
end

-- Function to update chest ESP
local function updateChestESP()
    -- Clear existing ESP
    for _, child in pairs(espFolder:GetChildren()) do
        child:Destroy()
    end
    
    -- Create new ESP for nearby chests
    local character = game:GetService("Players").LocalPlayer.Character
    if character then
        local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
        if humanoidRootPart then
            local playerPos = humanoidRootPart.Position
            local sandBlocks = game:GetService("Workspace").SandBlocks:GetChildren()
            
            for _, block in ipairs(sandBlocks) do
                if block:FindFirstChild("Chest") then
                    local distance = (block.Position - playerPos).magnitude
                    
                    -- Increased ESP range to 700 studs
                    if distance <= 700 then
                        local reward = block:FindFirstChild("Reward") and block.Reward.Value or 0
                        local chestType = block:FindFirstChild("Mat") and block.Mat.Value or ""
                        
                        -- Show ESP for chests that meet depth and reward criteria
                        if reward >= minReward and isDeepEnough(block.Position) then
                            -- If targeting specific chests, only show ESP for those types
                            if not targetSpecificChests or targetChestTypes[chestType] then
                                createChestESP(block, reward, chestType)
                            end
                        end
                    end
                end
            end
        end
    end
end

Section:NewButton("Allow Rainbow Chests", "yes", function()
    if allowrainbowchest then
        allowrainbowchest = false
        game.StarterGui:SetCore("SendNotification", {
            Title = "Button",
            Text = "Disallowed Rainbow Chests!",
            Duration = 3
        })
    else
        allowrainbowchest = true
        game.StarterGui:SetCore("SendNotification", {
            Title = "Button",
            Text = "Allowed Rainbow Chests!",
            Duration = 3
        })
    end
end)

allowonly1m = false
Section:NewButton("Only Allow 1M+ Chests", "yes", function()
    if allowonly1m then
        allowonly1m = false
        game.StarterGui:SetCore("SendNotification", {
            Title = "Button",
            Text = "Disallowed Only 1M+ Chests!",
            Duration = 3
        })
    else
        allowonly1m = true
        game.StarterGui:SetCore("SendNotification", {
            Title = "Button",
            Text = "Allowed Only 1M+ Chests!",
            Duration = 3
        })
    end
end)

Section:NewButton("farm 1 chest", "yes", function()
    local lp = game.Players.LocalPlayer
    if lp then
        local backpack = lp:FindFirstChild("Backpack")
        for _, tool in ipairs(backpack:GetChildren()) do
            toolname = tool.Name
            tool.Parent = workspace:WaitForChild(lp.Name)
        end
        if not toolname then
            tool = workspace:WaitForChild(lp.Name):FindFirstChildOfClass("Tool")
            toolname = tool.Name
        end
    end
    local player = game:GetService("Players").LocalPlayer
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
    local sandBlocks = game:GetService("Workspace").SandBlocks:GetChildren()
    local closestBlock = nil
    local closestDistance = math.huge
    local oldclosestpos = nil
    for _, block in ipairs(sandBlocks) do
        local distance = (block.Position - humanoidRootPart.Position).magnitude
        if distance < closestDistance and block:FindFirstChild("Chest") then
            local chestType = block:FindFirstChild("Mat") and block.Mat.Value or ""
            
            -- Check if we're targeting specific chests
            if targetSpecificChests and not targetChestTypes[chestType] then
                continue
            end
            
            if allowonly1m and block.Reward.Value >= 1000000 then
                if not allowrainbowchest and block.Mat.Value == "Rainbow Chest" then
                    continue
                end
                closestBlock = block
                closestDistance = distance
            elseif not allowonly1m then
                if not allowrainbowchest and block.Mat.Value == "Rainbow Chest" then
                    continue
                end
                closestBlock = block
                closestDistance = distance
            end
        end
    end
    
    if closestBlock then
        game.StarterGui:SetCore("SendNotification", {
            Title = "Crate",
            Text = "Reward: " .. tostring(closestBlock.Reward.Value) .. "!",
            Duration = 2
        })
        while true do
            humanoidRootPart.CFrame = CFrame.new(closestBlock.Position)
            game:GetService("Players").LocalPlayer.Character:FindFirstChild(toolname).RemoteClick:FireServer(workspace:WaitForChild("SandBlocks"):WaitForChild(closestBlock.Name))
            wait(0.1)
            
            local model = closestBlock:FindFirstChild("Chest")
            if not model or shouldstop then -- theres better ways but fuck off
                break
            end    
        end
    end
end)

Section:NewButton("loop farm chest", "yes", function()
    local lp = game.Players.LocalPlayer
    repeat
        if shouldstop then
            return
        end
        if lp then
            local backpack = lp:FindFirstChild("Backpack")
            for _, tool in ipairs(backpack:GetChildren()) do
                toolname = tool.Name
                tool.Parent = workspace:WaitForChild(lp.Name)
            end
            if not toolname then
                tool = workspace:WaitForChild(lp.Name):FindFirstChildOfClass("Tool")
                toolname = tool.Name
            end
        end
        
        -- Update chest ESP if enabled
        if chestESPEnabled then
            updateChestESP()
        end
        
        local player = game:GetService("Players").LocalPlayer
        local character = player.Character or player.CharacterAdded:Wait()
        local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
        local sandBlocks = game:GetService("Workspace").SandBlocks:GetChildren()
        local closestBlock = nil
        local closestDistance = math.huge
        local oldclosestpos = nil
        for _, block in ipairs(sandBlocks) do
            local distance = (block.Position - humanoidRootPart.Position).magnitude
            if distance < closestDistance and block:FindFirstChild("Chest") then
                local chestType = block:FindFirstChild("Mat") and block.Mat.Value or ""
                
                -- Check if we're targeting specific chests
                if targetSpecificChests and not targetChestTypes[chestType] then
                    continue
                end
                
                if allowonly1m and block.Reward.Value >= 1000000 then
                    if not allowrainbowchest and block.Mat.Value == "Rainbow Chest" then
                        continue
                    end
                    closestBlock = block
                    closestDistance = distance
                elseif not allowonly1m then
                    if not allowrainbowchest and block.Mat.Value == "Rainbow Chest" then
                        continue
                    end
                    closestBlock = block
                    closestDistance = distance
                end
            end
        end
        
        if closestBlock then
            local chestType = closestBlock:FindFirstChild("Mat") and closestBlock.Mat.Value or "Unknown"
            game.StarterGui:SetCore("SendNotification", {
                Title = "Crate",
                Text = chestType .. ": " .. tostring(closestBlock.Reward.Value) .. "!",
                Duration = 3
            })
            while true do
                humanoidRootPart.CFrame = CFrame.new(closestBlock.Position)
                game:GetService("Players").LocalPlayer.Character:FindFirstChild(toolname).RemoteClick:FireServer(workspace:WaitForChild("SandBlocks"):WaitForChild(closestBlock.Name))
                wait(0.1)
                
                local model = closestBlock:FindFirstChild("Chest")
                if not model or shouldstop then
                    break
                end
            end
        end
        wait(0.05)
    until shouldstop == true
end)

Section:NewButton("stop farm", "yes", function()
    shouldstop = not shouldstop
    if shouldstop then
        game.StarterGui:SetCore("SendNotification", {
            Title = "Stop Farm",
            Text = "Stopped Farm",
            Duration = 2
        })
    else
        game.StarterGui:SetCore("SendNotification", {
            Title = "Stop Farm",
            Text = "Allowed Farm",
            Duration = 2
        })
    end
end)

shouldstop2 = false
Section:NewButton("Mine Tunnel Loop", "yes", function()
    local lp = game.Players.LocalPlayer
    repeat
        if shouldstop2 then
            return
        end
        if lp then
            local backpack = lp:FindFirstChild("Backpack")
            for _, tool in ipairs(backpack:GetChildren()) do
                toolname = tool.Name
                tool.Parent = workspace:WaitForChild(lp.Name)
            end
            if not toolname then
                tool = workspace:WaitForChild(lp.Name):FindFirstChildOfClass("Tool")
                toolname = tool.Name
            end
        end

        local character = lp.Character or lp.CharacterAdded:Wait()
        local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

        local raycastParams = RaycastParams.new()
        raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
        raycastParams.FilterDescendantsInstances = {game:GetService("Workspace").SandBlocks}
        
        local function findClosestSandBlock()
            local result = workspace:Raycast(humanoidRootPart.Position, Vector3.new(0, -7, 0), raycastParams)
            if result and result.Instance then
                return result.Instance
            end
            return nil
        end
        closestBlock = findClosestSandBlock()
        if closestBlock then
            while true do
                humanoidRootPart.CFrame = CFrame.new(closestBlock.Position + Vector3.new(0, 1, 0))
                game:GetService("Players").LocalPlayer.Character:FindFirstChild(toolname).RemoteClick:FireServer(workspace:WaitForChild("SandBlocks"):WaitForChild(closestBlock.Name))
                wait(0.125)
                
                local model = closestBlock:FindFirstChild("Health")
                if not model or shouldstop2 then
                    break
                end
            end
        end
        wait(0.05)
    until shouldstop2 == true
end)

Section:NewButton("Stop Loop", "yes", function()
    shouldstop2 = true
    wait(0.125)
    shouldstop2 = false
end)

Section:NewButton("Sell", "yes", function()
    -- Use the enhanced sell function
    performSellX()
end)

-- Settings have been moved to the Rebirth tab

local CrateTab = Window:NewTab("Crates")
local CrateSection = CrateTab:NewSection("Crates")
CrateSection:NewButton("Buy Open Tier4 Hat Crate", "yes", function()
    local args = {
        [1] = game:GetService("ReplicatedStorage"):WaitForChild("Crates"):WaitForChild("Tier4Hat"),
        [2] = game.Players.LocalPlayer.Name,
        [3] = 1
    }
    game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("BuyCrate"):FireServer(unpack(args))
    game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("SendOpenCrate"):FireServer(game:GetService("ReplicatedStorage"):WaitForChild("Crates"):WaitForChild("Tier4Hat"))    
end)
CrateSection:NewButton("Buy Open Tier5 Hat Crate", "yes", function()
    local args = {
        [1] = game:GetService("ReplicatedStorage"):WaitForChild("Crates"):WaitForChild("Tier5Hat"),
        [2] = game.Players.LocalPlayer.Name,
        [3] = 1
    }
    game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("BuyCrate"):FireServer(unpack(args))
    game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("SendOpenCrate"):FireServer(game:GetService("ReplicatedStorage"):WaitForChild("Crates"):WaitForChild("Tier5Hat"))    
end)
CrateSection:NewButton("Buy Open Tier6 Hat Crate", "yes", function()
    local args = {
        [1] = game:GetService("ReplicatedStorage"):WaitForChild("Crates"):WaitForChild("Tier6Hat"),
        [2] = game.Players.LocalPlayer.Name,
        [3] = 1
    }
    game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("BuyCrate"):FireServer(unpack(args))
    game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("SendOpenCrate"):FireServer(game:GetService("ReplicatedStorage"):WaitForChild("Crates"):WaitForChild("Tier6Hat"))    
end)

local RebirthTab = Window:NewTab("Rebirth")
local RebirthSection = RebirthTab:NewSection("Rebirth")

-- Add depth setting slider to Rebirth tab
RebirthSection:NewSlider("Min Depth", "Set minimum depth to farm (below surface)", 10000, 100, function(value)
    minDepth = value
    game.StarterGui:SetCore("SendNotification", {
        Title = "Depth Setting",
        Text = "Set minimum depth to " .. tostring(value),
        Duration = 2
    })
end)

-- Add toggle for targeting specific chest types
RebirthSection:NewButton("Target Specific Chests", "Toggle to target Snow, Magma, Knight's, and Mermaid Chests", function()
    targetSpecificChests = not targetSpecificChests
    if targetSpecificChests then
        game.StarterGui:SetCore("SendNotification", {
            Title = "Target Chests",
            Text = "Now targeting specific chest types only",
            Duration = 3
        })
    else
        game.StarterGui:SetCore("SendNotification", {
            Title = "Target Chests",
            Text = "Now targeting all chests",
            Duration = 3
        })
    end
    
    -- Update ESP to reflect the new targeting preference
    if chestESPEnabled then
        updateChestESP()
    end
end)

RebirthSection:NewButton("Rebirth", "Rebirth", function()
    local lp = game.Players.LocalPlayer
    coins = lp.leaderstats.Coins.Value
    rebirthcoins = lp.PlayerGui.Gui.Rebirth.Needed.Coins.Amount.Text:gsub(",", "")
    print(coins, rebirthcoins)
    if coins > tonumber(rebirthcoins) then
        game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("Rebirth"):FireServer()
        game.StarterGui:SetCore("SendNotification", {
            Title = "Rebirth",
            Text = "Successfully rebirthed!",
            Duration = 5
        })
    else
        game.StarterGui:SetCore("SendNotification", {
            Title = "Rebirth",
            Text = "Not enough Coins.! Need: " .. rebirthcoins .. "!",
            Duration = 5
        })
    end
end)

-- Enhanced loop rebirth farm - now with specific chest type targeting
RebirthSection:NewButton("loop rebirth farm", "yes", function()
    local lp = game.Players.LocalPlayer
    repeat
        if shouldstop then
            return
        end
        if lp then
            local backpack = lp:FindFirstChild("Backpack")
            for _, tool in ipairs(backpack:GetChildren()) do
                toolname = tool.Name
                tool.Parent = workspace:WaitForChild(lp.Name)
            end
            if not toolname then
                tool = workspace:WaitForChild(lp.Name):FindFirstChildOfClass("Tool")
                toolname = tool.Name
            end
        end
        
        -- Update chest ESP if enabled
        if chestESPEnabled then
            updateChestESP()
        end
        
        local player = game:GetService("Players").LocalPlayer
        local character = player.Character or player.CharacterAdded:Wait()
        local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
        local sandBlocks = game:GetService("Workspace").SandBlocks:GetChildren()
        local closestBlock = nil
        local closestDistance = math.huge
        local oldclosestpos = nil
        
        -- Find eligible chests
        for _, block in ipairs(sandBlocks) do
            local distance = (block.Position - humanoidRootPart.Position).magnitude
            
            -- Check if it's a chest, if it's deep enough, and if it meets value requirements
            if distance < closestDistance and block:FindFirstChild("Chest") and
               isDeepEnough(block.Position) and block:FindFirstChild("Reward") and 
               block.Reward.Value >= minReward then
                
                local chestType = block:FindFirstChild("Mat") and block.Mat.Value or ""
                
                -- Check if it's a rainbow chest
                if chestType == "Rainbow Chest" and not allowrainbowchest then
                    continue
                end
                
                -- Check if we're targeting specific chests
                if targetSpecificChests and not targetChestTypes[chestType] then
                    continue
                end
                
                -- Check if we're only allowing 1M+ chests
                if allowonly1m and block.Reward.Value < 1000000 then
                    continue
                end
                
                closestBlock = block
                closestDistance = distance
            end
        end
        
        -- If we found a valid chest, go mine it
        if closestBlock then
            local chestType = closestBlock:FindFirstChild("Mat") and closestBlock.Mat.Value or "Unknown"
            game.StarterGui:SetCore("SendNotification", {
                Title = chestType,
                Text = "Reward: " .. tostring(closestBlock.Reward.Value) .. " (Depth: " .. math.abs(closestBlock.Position.Y) .. ")",
                Duration = 3
            })
            while true do
                humanoidRootPart.CFrame = CFrame.new(closestBlock.Position)
                game:GetService("Players").LocalPlayer.Character:FindFirstChild(toolname).RemoteClick:FireServer(workspace:WaitForChild("SandBlocks"):WaitForChild(closestBlock.Name))
                wait(0.1)
                
                local model = closestBlock:FindFirstChild("Chest")
                -- check if can rebirth
                coins = lp.leaderstats.Coins.Value
                rebirthcoins = lp.PlayerGui.Gui.Rebirth.Needed.Coins.Amount.Text:gsub(",", "")
                if coins > tonumber(rebirthcoins) then
                    game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("Rebirth"):FireServer()
                    game.StarterGui:SetCore("SendNotification", {
                        Title = "Auto Rebirth",
                        Text = "Successfully rebirthed!",
                        Duration = 2
                    })
                end
                
                -- Check if we need to stop
                if not model or shouldstop then
                    break
                end
            end
        else
            -- If no suitable chest found, try to teleport to a deep location
            local targetDepth = -minDepth - 20  -- Go a bit deeper than minimum
            humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position.X, targetDepth, humanoidRootPart.Position.Z)
            wait(0.5)  -- Wait briefly before searching again
        end
        
        -- Check if we can rebirth
        coins = lp.leaderstats.Coins.Value
        rebirthcoins = lp.PlayerGui.Gui.Rebirth.Needed.Coins.Amount.Text:gsub(",", "")
        if coins > tonumber(rebirthcoins) then
            game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("Rebirth"):FireServer()
            game.StarterGui:SetCore("SendNotification", {
                Title = "Auto Rebirth",
                Text = "Successfully rebirthed!",
                Duration = 2
            })
        end
        
        wait(0.3)
    until shouldstop == true
end)

RebirthSection:NewButton("stop farm", "yes", function()
    shouldstop = not shouldstop
    if shouldstop then
        game.StarterGui:SetCore("SendNotification", {
            Title = "Stop Farm",
            Text = "Stopped Farm",
            Duration = 2
        })
    else
        game.StarterGui:SetCore("SendNotification", {
            Title = "Stop Farm",
            Text = "Allowed Farm",
            Duration = 2
        })
    end
end)

-- Sell keybind (R key)
game:GetService("UserInputService").InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.R then -- Press R to manually sell
        performSellX()
    end
end)

-- Update ESP periodically
spawn(function()
    while wait(0.5) do
        if chestESPEnabled then
            updateChestESP()
        end
    end
end)

-- Notify that the modified script is loaded
game.StarterGui:SetCore("SendNotification", {
    Title = "Enhanced Script Loaded",
    Text = "Added targeting for specific chest types in rebirth section",
    Duration = 5
})

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

-- Wait for PlayerGui
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")

-- Hide everything that looks like a notification
while task.wait(0.1) do
    for _, gui in pairs(PlayerGui:GetChildren()) do
        if gui:IsA("ScreenGui") then
            -- Look for common notification container names
            for _, possibleName in pairs({"Notification", "Alert", "Message", "Popup", "Notice"}) do
                for _, obj in pairs(gui:GetDescendants()) do
                    if obj.Name:find(possibleName) and (obj:IsA("Frame") or obj:IsA("ImageLabel")) then
                        obj.Visible = false
                    end
                end
            end
            
            -- Also check for the specific backpack full text
            for _, textLabel in pairs(gui:GetDescendants()) do
                if textLabel:IsA("TextLabel") then
                    if textLabel.Text == "Backpack Full" or textLabel.Text:find("Backpack Full") then
                        -- Get all ancestors and hide them
                        local current = textLabel
                        while current ~= gui do
                            current.Visible = false
                            current = current.Parent
                        end
                    end
                end
            end
        end
    end
end

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: