---------- [ Libraries & Services ]----------
local Library = loadstring(game:HttpGet("https://pastebin.com/raw/b5QLVFiM"))()

local Players             = game:GetService("Players")
local StarterGui          = game:GetService("StarterGui")
local TweenService        = game:GetService("TweenService")
local UserInputService    = game:GetService("UserInputService")
local ReplicatedStorage   = game:GetService("ReplicatedStorage")
local PathfindingService  = game:GetService("PathfindingService")
local VirtualInputManager = game:GetService("VirtualInputManager")
local RunService          = game:GetService("RunService")

local player     = Players.LocalPlayer
local character  = player.Character or player.CharacterAdded:Wait()
local humanoid   = character:WaitForChild("Humanoid")
local rootPart   = character:WaitForChild("HumanoidRootPart")
local backpack   = player:WaitForChild("Backpack")
local playerGui  = player:WaitForChild("PlayerGui")
local mouse      = player:GetMouse()

---------- [ Global Variables & Settings ]----------
local Farm                 = false
local Rebirth              = false
local IsSelling            = false
local AutoFarmAI           = false
local ESPEnabled           = false
local FarmPaused           = false
local XRayEnabled          = false
local AutoSellEnabled      = false
local ESPPlayerEnabled     = false
local VisualEffectsEnabled = true
local ToolDestroyerEnabled = false

local GodModeEnabled       = false
local InvisibleEnabled     = false
local NoclipEnabled        = false  -- New: NoClip

local CurrentChest         = nil
local FarmingSpeed         = 0.001
local XRayTransparency     = 0.2

local PlayerHighlights     = {}  -- Stores ESP info for players
local ChestHighlights      = {}  -- Stores ESP info for chests
local ESPLineObjects       = {}  -- Stores ESP lines for players

-- Additional Tools (in Tools tab)
local InfiniteJumpEnabled  = false
local FlyEnabled           = false
local FlySpeed             = 50     -- Default Fly Speed
local SpeedBoostEnabled    = false
local SpeedBoostMultiplier = 2      -- Default Boost Multiplier
local BaseWalkSpeed        = humanoid.WalkSpeed  -- Save initial walk speed

-- Auto Buy & Server Hop toggles
local AutoBuyShovelsEnabled   = false
local AutoBuyBackpacksEnabled = false
local AutoBuyPetsEnabled      = false
local AutoBuyCratesEnabled    = false
local AutoOpenCratesEnabled   = false
local AutoServerHopEnabled    = false

-- Anti-AFK variable
local AntiAFKEnabled = false

-- Infinite Yield
local IY = false

-- Variabel tambahan untuk auto–buy crate: pilih crate dan jumlahnya  
local chosenCrate    = "Tier1"  -- default; sesuaikan dengan nama crate di folder Crates
local chosenQuantity = 1

-- Data item untuk auto–buy (asumsi terdapat folder–folder berikut di ReplicatedStorage)
local itemData = {
    shovels   = ReplicatedStorage:WaitForChild("Shovels"),
    backpacks = ReplicatedStorage:WaitForChild("Backpacks"),
    pets      = ReplicatedStorage:WaitForChild("Pets"),
    crates    = ReplicatedStorage:WaitForChild("Crates")
}

---------- [ Helper Functions ]----------
-- Fungsi untuk mengirim notifikasi ke player
local function notify(title, text)
    StarterGui:SetCore("SendNotification", {
        Title    = title,
        Text     = text,
        Duration = 5,
    })
end

-- Nonaktifkan koneksi Anti-AFK (metode 1)
local function disableAFK()
    for _, con in ipairs(getconnections(player.Idled)) do
        con:Disable()
    end
end

-- Metode Anti-AFK dengan input virtual (metode 2)
local function antiAFKLoop()
    while AntiAFKEnabled do
        task.wait(50)
        pcall(function()
            VirtualInputManager:SendKeyEvent(true, "LeftShift", false, nil)
            VirtualInputManager:SendKeyEvent(false, "LeftShift", false, nil)
        end)
    end
end

------------------------------------------------------------------
-- LOGIKA AUTO BUY ITEM (BERDASARKAN HARGA DAN COIN)
------------------------------------------------------------------
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer

-------------------------------------------------------------------
-- Remote Event yang digunakan untuk pembelian item
-- (dari daftar remote event: "ReplicatedStorage.Events.Checkout")
-------------------------------------------------------------------
local checkoutEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("Checkout")

-------------------------------------------------------------------
-- Tabel default item (digunakan bila deteksi item gagal)
-------------------------------------------------------------------
local defaultItems = {
    shovels   = "BasicShovel",
    backpacks = "BasicBackpack",
    pets      = "None"
}

-------------------------------------------------------------------
-- Folder data item
-- Sesuaikan struktur data Anda; misalnya, data item disimpan di ReplicatedStorage
-------------------------------------------------------------------
local itemData = {
    shovels   = ReplicatedStorage:WaitForChild("Shovels"),    -- misal: folder Shovels
    backpacks = ReplicatedStorage:WaitForChild("Backpacks"),  -- misal: folder Backpacks
    pets      = ReplicatedStorage:WaitForChild("Pets")        -- misal: folder Pets
}

-------------------------------------------------------------------
-- Fungsi untuk memperbarui data pemain (karakter, backpack, tool)
-------------------------------------------------------------------
local function updatePlayerData()
    local character = player.Character or player.CharacterAdded:Wait()
    local backpack = player:WaitForChild("Backpack")
    
    -- Cari tool di dalam karakter, jika tidak ada, cari di backpack
    local tool = character:FindFirstChildOfClass("Tool")
    if not tool then
        tool = backpack:FindFirstChildOfClass("Tool")
    end

    return {
        Character = character,
        Backpack  = backpack,
        Tool      = tool
    }
end

-------------------------------------------------------------------
local function getCurrentItem(item_type)
    local data = updatePlayerData()
    item_type = string.lower(item_type)
    
    if item_type == "shovels" then
        if data.Tool then
            print("[Debug] Current shovel (dari Tool): " .. data.Tool.Name)
            return data.Tool.Name
        else
            print("[Debug] Tool tidak ditemukan, gunakan default shovel: " .. defaultItems.shovels)
            return defaultItems.shovels
        end

    elseif item_type == "backpacks" then
        -- Contoh: deteksi backpack berupa Model di karakter yang memiliki child bernama "BackpackIdentifier"
        for _, obj in ipairs(data.Character:GetChildren()) do
            if obj:IsA("Model") and obj:FindFirstChild("BackpackIdentifier") then
                print("[Debug] Current backpack (dari karakter): " .. obj.Name)
                return obj.Name
            end
        end
        print("[Debug] Backpack tidak terdeteksi, gunakan default: " .. defaultItems.backpacks)
        return defaultItems.backpacks

    elseif item_type == "pets" then
        -- Contoh: asumsikan pet disimpan di dalam folder "PetHolder" di karakter
        local petHolder = data.Character:FindFirstChild("PetHolder")
        if petHolder and #petHolder:GetChildren() > 0 then
            local pet = petHolder:GetChildren()[1]
            print("[Debug] Current pet: " .. pet.Name)
            return pet.Name
        else
            print("[Debug] Tidak ada pet ditemukan, gunakan default: " .. defaultItems.pets)
            return defaultItems.pets
        end

    else
        warn("[Debug] Tipe item tidak dikenal: " .. item_type)
        return nil
    end
end

-------------------------------------------------------------------
local function getPlayerCoins()
    local leaderstats = player:WaitForChild("leaderstats")
    local coins = leaderstats:WaitForChild("Coins")
    print("[Debug] Coins: " .. coins.Value)
    return coins.Value
end

-------------------------------------------------------------------
local function getNextBestItem(item_type, max_price)
    local current_item_name = getCurrentItem(item_type)
    if not current_item_name then
        return nil
    end

    local folder = itemData[item_type]
    if not folder then
        warn("[Debug] Data item untuk tipe '" .. item_type .. "' tidak ditemukan!")
        return nil
    end

    local current_item = folder:FindFirstChild(current_item_name)
    local min_price = 0
    if current_item and current_item:FindFirstChild("Price") then
        min_price = current_item.Price.Value
    end
    print("[Debug] Harga current " .. item_type .. " (" .. current_item_name .. "): " .. tostring(min_price))
    
    local next_best_item = nil
    for _, item in ipairs(folder:GetChildren()) do
        if item:FindFirstChild("Price") then
            local price = item.Price.Value
            if price > min_price and price <= max_price then
                if not next_best_item or price < next_best_item.Price.Value then
                    next_best_item = item
                end
            end
        end
    end
    
    if next_best_item then
        print("[Debug] Candidate upgrade untuk " .. item_type .. ": " .. next_best_item.Name .. " (Price: " .. next_best_item.Price.Value .. ")")
    else
        print("[Debug] Tidak ada candidate upgrade yang memenuhi untuk " .. item_type)
    end
    
    return next_best_item
end

-------------------------------------------------------------------
-- Fungsi untuk membeli upgrade item berikutnya.
-------------------------------------------------------------------
local function buyNextBestItem(item_type)
    local coins = getPlayerCoins()
    local nextItem = getNextBestItem(item_type, coins)
    if nextItem then
        print("[AutoBuy] Mencoba membeli upgrade " .. item_type .. ": " .. nextItem.Name .. " (Price: " .. nextItem.Price.Value .. ")")
        checkoutEvent:FireServer(nextItem.Name)
        -- Jika perlu, setelah pembelian bisa dipanggil logika tambahan untuk meng-equip item baru.
    else
        print("[AutoBuy] Upgrade tidak ditemukan atau tidak terjangkau untuk " .. item_type)
    end
end

-------------------------------------------------------------------
-- Contoh pemanggilan fungsi upgrade berdasarkan toggle
-------------------------------------------------------------------
local autoBuyShovels   = true
local autoBuyBackpacks = true
local autoBuyPets      = true

if autoBuyShovels then
    buyNextBestItem("shovels")
end

if autoBuyBackpacks then
    buyNextBestItem("backpacks")
end

if autoBuyPets then
    buyNextBestItem("pets")
end

------------------------------------------------------------------
-- LOGIKA AUTO BUY & OPEN CRATES
------------------------------------------------------------------

-- Fungsi untuk membeli crate
local function buyCrate(crateName, targetName, quantity)
    local crate = itemData.crates:FindFirstChild(crateName)
    if crate then
         print("[Crate] Buying crate: " .. crateName .. " for " .. targetName .. " (" .. tostring(quantity) .. ")")
         ReplicatedStorage.Events.BuyCrate:FireServer(crate, targetName, quantity)
    else
         warn("Crate not found: " .. crateName)
    end
end

-- Fungsi untuk membuka crate
local function openCrate(crateName)
    local crate = itemData.crates:FindFirstChild(crateName)
    if crate then
         print("[Crate] Opening crate: " .. crateName)
         ReplicatedStorage.Events.OpenCrate:FireServer(crate)
    else
         warn("Crate not found: " .. crateName)
    end
end

------------------------------------------------------------------
-- LOOP AUTO BUY / AUTO OPEN (TERINTEGRASI DENGAN LOGIKA DI ATAS)
------------------------------------------------------------------

local function autoBuyShovelsLoop()
    while AutoBuyShovelsEnabled do
        pcall(function() buyNextBestItem("shovels") end)
        task.wait(0.5)  -- gunakan delay lebih lama (0.5 detik) untuk debugging
    end
end

local function autoBuyBackpacksLoop()
    while AutoBuyBackpacksEnabled do
        pcall(function() buyNextBestItem("backpacks") end)
        task.wait(0.5)
    end
end

local function autoBuyPetsLoop()
    while AutoBuyPetsEnabled do
        pcall(function() buyNextBestItem("pets") end)
        task.wait(0.5)
    end
end

local function autoBuyCratesLoop()
    while AutoBuyCratesEnabled do
        pcall(function() buyCrate(chosenCrate, player.Name, chosenQuantity) end)
        task.wait(0.5)
    end
end

local function autoOpenCratesLoop()
    while AutoOpenCratesEnabled do
        pcall(function() openCrate(chosenCrate) end)
        task.wait(0.5)
    end
end

local function autoServerHopLoop()
    while AutoServerHopEnabled do
        pcall(function()
            -- Contoh: ReplicatedStorage.Events.ServerHop:FireServer()
        end)
        task.wait(0.5)
    end
end

------------------------------------------------------------------
-- FUNGSI–FUNGSI LAINNYA (TIDAK DIUBAH DARI SCRIPT ASLI)
------------------------------------------------------------------

-- God Mode: Pastikan health selalu maksimum
local function enableGodMode()
    spawn(function()
        while GodModeEnabled do
            if humanoid and humanoid.Health < humanoid.MaxHealth then
                humanoid.Health = humanoid.MaxHealth
            end
            task.wait(0.1)
        end
    end)
end

-- Atur karakter agar tidak terlihat (transparansi)
local function setInvisible(state)
    if character then
        for _, part in ipairs(character:GetDescendants()) do
            if part:IsA("BasePart") then
                part.Transparency = state and 1 or 0
            end
        end
    end
end

-- Teleport ke pemain lain secara acak
local function teleportToRandomPlayer()
    local playersList = Players:GetPlayers()
    local candidates = {}
    for _, p in ipairs(playersList) do
        if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
            table.insert(candidates, p)
        end
    end
    if #candidates > 0 then
        local target = candidates[math.random(1, #candidates)]
        if target and target.Character and target.Character:FindFirstChild("HumanoidRootPart") then
            rootPart.CFrame = target.Character.HumanoidRootPart.CFrame * CFrame.new(5, 0, 0)
            notify("Teleport", "Teleported to " .. target.Name)
        end
    end
end

-- Acak posisi semua pemain di sekitar player lokal
local function randomizePlayerPositions()
    local localChar = player.Character
    if not (localChar and localChar:FindFirstChild("HumanoidRootPart")) then return end
    local rootPos = localChar.HumanoidRootPart.CFrame
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
            pcall(function()
                p.Character.HumanoidRootPart.CFrame = rootPos * CFrame.new(math.random(-10,10), 0, math.random(-10,10))
            end)
        end
    end
    notify("Troll", "Player positions randomized.")
end

-- Teleport ke lokasi acak di sekitar
local function teleportToRandomLocation()
    local randomOffset = Vector3.new(math.random(-50,50), 0, math.random(-50,50))
    rootPart.CFrame = CFrame.new(rootPart.Position + randomOffset)
    notify("Teleport", "Teleported to a random location.")
end

-- Fitur ESP: Buat atau perbarui garis ESP dari player lokal ke target
local function updateESPLine(targetPlayer)
    if targetPlayer.Character and targetPlayer.Character:FindFirstChild("HumanoidRootPart") then
        local startPos = rootPart.Position
        local targetPos = targetPlayer.Character.HumanoidRootPart.Position

        if not ESPLineObjects[targetPlayer] then
            local attachment0 = Instance.new("Attachment")
            attachment0.WorldPosition = startPos
            attachment0.Parent = rootPart

            local attachment1 = Instance.new("Attachment")
            attachment1.WorldPosition = targetPos
            attachment1.Parent = targetPlayer.Character.HumanoidRootPart

            local beam = Instance.new("Beam")
            beam.Attachment0 = attachment0
            beam.Attachment1 = attachment1
            beam.Color = ColorSequence.new(Color3.new(0, 1, 0))
            beam.Width0 = 0.1
            beam.Width1 = 0.1
            beam.FaceCamera = true
            beam.Parent = rootPart

            ESPLineObjects[targetPlayer] = {beam = beam, attachment0 = attachment0, attachment1 = attachment1}
        else
            local objs = ESPLineObjects[targetPlayer]
            objs.attachment0.WorldPosition = startPos
            objs.attachment1.WorldPosition = targetPos
        end
    end
end

-- Bersihkan garis ESP untuk pemain tertentu
local function removeESPLine(targetPlayer)
    if ESPLineObjects[targetPlayer] then
        local objs = ESPLineObjects[targetPlayer]
        if objs.beam then objs.beam:Destroy() end
        if objs.attachment0 then objs.attachment0:Destroy() end
        if objs.attachment1 then objs.attachment1:Destroy() end
        ESPLineObjects[targetPlayer] = nil
    end
end

------------------------------------------------------------------
-- [ Window & Tabs Setup ]
------------------------------------------------------------------
local Window = Library:CreateWindow('JustShare - Hub Advanced Pro')

local Tabs = {
    Home  = Window:addTab('•Home + Settings'),
    ESP   = Window:addTab('•ESP'),
    Troll = Window:addTab('•Troll'),
    Tools = Window:addTab('•Universal'),
}

------------------------------------------------------------------
-- [ SECTION: HOME TAB ]
------------------------------------------------------------------
local Home_Left  = Tabs.Home:addSection()    -- Primary Settings Section
local Home_Right = Tabs.Home:addSection()    -- Advanced Settings Section

local Main_Home = Home_Left:addMenu("#Home")

------------------------------------------------------------------
-- [ HOME TAB FUNCTIONS ]
------------------------------------------------------------------
local function DestroyTools()
    while ToolDestroyerEnabled do
        if character then
            for _, tool in ipairs(character:GetChildren()) do
                if tool:IsA("Tool") then
                    pcall(function() tool:Destroy() end)
                end
            end
        end
        if backpack then
            for _, tool in ipairs(backpack:GetChildren()) do
                if tool:IsA("Tool") then
                    pcall(function() tool:Destroy() end)
                end
            end
        end
        task.wait(0.1)
    end
end

local function Sell()
    if IsSelling then return end
    IsSelling = true

    local localChar = player.Character
    if localChar and localChar:FindFirstChild("HumanoidRootPart") then
        local oldPos = localChar.HumanoidRootPart.CFrame
        localChar.HumanoidRootPart.CFrame = CFrame.new(3, 10, -160)
        task.wait(0.1)
        pcall(function()
            ReplicatedStorage.Events.AreaSell:FireServer()
        end)
        task.wait(0.1)
        localChar.HumanoidRootPart.CFrame = oldPos
    end

    IsSelling = false
end

local function setPositionAtChest(targetPosition, tool)
    if tool.Name == "Dynamite" or tool.Name == "Nuke" then
        local offset = Vector3.new(0, 5, -3)
        rootPart.CFrame = CFrame.new(targetPosition + offset, targetPosition)
    else
        if (rootPart.Position - targetPosition).Magnitude > 0.5 then
            rootPart.CFrame = CFrame.new(targetPosition)
        end
    end
end

local function AutoFarmLoop()
    while Farm do
        if FarmPaused then
            task.wait(0.5)
        else
            local localChar = player.Character
            if not localChar then 
                task.wait(0.5)
                continue
            end

            local tool = localChar:FindFirstChildOfClass("Tool") or backpack:FindFirstChildOfClass("Tool")
            if not tool then
                notify("Error!", "No tool found! Auto Farm disabled.")
                Farm = false
                return
            elseif not localChar:FindFirstChildOfClass("Tool") then
                pcall(function() localChar.Humanoid:EquipTool(tool) end)
                task.wait(0.1)
            end

            if CurrentChest and CurrentChest.Parent then
                local targetPosition = CurrentChest.Position
                setPositionAtChest(targetPosition, tool)

                if tool:FindFirstChild("RemoteClick") then
                    pcall(function() tool.RemoteClick:FireServer(CurrentChest) end)
                end
                task.wait(FarmingSpeed)

                if AutoSellEnabled and playerGui.Gui and playerGui.Gui.Popups and 
                   playerGui.Gui.Popups.BackpackFull and playerGui.Gui.Popups.BackpackFull.Visible then
                    FarmPaused = true
                    Sell()
                    task.wait(0.5)
                    FarmPaused = false
                end
            else
                CurrentChest = nil
                for _, v in ipairs(workspace.SandBlocks:GetChildren()) do
                    if not Farm then break end
                    if v:FindFirstChild("Chest") then
                        CurrentChest = v
                        v.CanCollide = false
                        if localChar then
                            local targetPosition = v.Position
                            setPositionAtChest(targetPosition, tool)
                            
                            if tool:FindFirstChild("RemoteClick") then
                                pcall(function() tool.RemoteClick:FireServer(v) end)
                            end
                            task.wait(0.05)
                        end
                        break
                    end
                end
            end
        end
        task.wait(0.05)
    end
end

------------------------------------------------------------------
-- [ HOME TAB TOGGLES & TRIGGERS ]
------------------------------------------------------------------
Main_Home:addToggle('Auto Farm', false, function(state)
    Farm = state
    if state then
        local localChar = player.Character
        local tool = localChar and localChar:FindFirstChildOfClass("Tool") or backpack:FindFirstChildOfClass("Tool")
        if not tool then
            notify("Error!", "No tool found! Auto Farm disabled.")
            Farm = false
            return
        end
        if localChar and not localChar:FindFirstChildOfClass("Tool") then
            pcall(function() localChar.Humanoid:EquipTool(tool) end)
            task.wait(0.1)
        end
        notify("Success!", "Auto Farm enabled.")
        task.spawn(AutoFarmLoop)
    else
        notify("Info", "Auto Farm disabled.")
    end
end)

Main_Home:addToggle('Auto Farm With AI', false, function(state)
    AutoFarmAI = state
    if AutoFarmAI then
        notify("Auto Farm AI Enabled", "Auto Farm AI is now active.")
        task.spawn(function() 
            while AutoFarmAI do
                task.wait(1)
            end
        end)
    else
        notify("Auto Farm AI Disabled", "Auto Farm AI is now disabled.")
    end
end)

Main_Home:addToggle('Auto Sell', false, function(state)
    AutoSellEnabled = state
    notify("Success!", "Auto Sell " .. (state and "enabled." or "disabled."))
end)

Main_Home:addToggle('Auto Rebirth', false, function(state)
    Rebirth = state
    if Rebirth then
        notify("Auto Rebirth Enabled", "Auto Rebirth is now active.")
        task.spawn(function()
            while Rebirth do
                task.wait(1)
                local coinsText = playerGui.Gui.Buttons.Coins.Amount.Text:gsub(',', '')
                local rebirthCostText = playerGui.Gui.Rebirth.Needed.Coins.Amount.Text:gsub(',', '')
                local coins = tonumber(coinsText)
                local cost  = tonumber(rebirthCostText)
                if coins and cost and coins > cost then 
                    warn('Rebirth triggered!')
                    pcall(function() 
                        ReplicatedStorage.Events.Rebirth:FireServer()
                    end)
                    if playerGui.ToolBox then
                        playerGui.ToolBox.Text = "Bucket"
                    end
                    repeat task.wait(0.1) until playerGui.Gui.Popups.GiveReward and playerGui.Gui.Popups.GiveReward.Visible == true
                    playerGui.Gui.Popups.GiveReward.Visible = false
                    task.wait()
                end
            end
        end)
    end
end)

-- Toggle Auto Buy untuk Shovels, Backpacks, dan Pets
Main_Home:addToggle("Auto Buy Shovels", false, function(state)
    AutoBuyShovelsEnabled = state
    if state then
        task.spawn(autoBuyShovelsLoop)
    end
end)

Main_Home:addToggle("Auto Buy Backpacks (Not Work)", false, function(state)
    AutoBuyBackpacksEnabled = state
    if state then
        task.spawn(autoBuyBackpacksLoop)
    end
end)

Main_Home:addToggle("Auto Buy Pets (Not Work)", false, function(state)
    AutoBuyPetsEnabled = state
    if state then
        task.spawn(autoBuyPetsLoop)
    end
end)

-- Toggle Auto Buy dan Auto Open Crates (gunakan variabel chosenCrate dan chosenQuantity)
Main_Home:addToggle("Auto Buy Crates (Test)", false, function(state)
    AutoBuyCratesEnabled = state
    if state then
        task.spawn(autoBuyCratesLoop)
    end
end)

Main_Home:addToggle("Auto Open Crates (Not Work)", false, function(state)
    AutoOpenCratesEnabled = state
    if state then
        task.spawn(autoOpenCratesLoop)
    end
end)

--[[
Main_Home:addToggle("Auto Server Hop", false, function(state)
    AutoServerHopEnabled = state
    if state then
        task.spawn(autoServerHopLoop)
    end
end)
--]]

Main_Home:addToggle('X-Ray', false, function(state)
    XRayEnabled = state
    if XRayEnabled then
        for _, obj in ipairs(workspace:GetDescendants()) do
            if obj:IsA("BasePart") and not obj:IsDescendantOf(player.Character) then
                obj.Transparency = XRayTransparency
            end
        end
        notify("X-Ray Enabled", "Objects are now transparent.")
    else
        for _, obj in ipairs(workspace:GetDescendants()) do
            if obj:IsA("BasePart") then
                obj.Transparency = 0
            end
        end
        notify("X-Ray Disabled", "Objects are now back to normal.")
    end
end)

local Home_Right_Menu = Home_Right:addMenu("#Settings")
Home_Right_Menu:addTextbox('Farming Speed', tostring(FarmingSpeed), function(value)
    local newSpeed = tonumber(value)
    if newSpeed and newSpeed > 0 then
        FarmingSpeed = newSpeed
        notify("Farming Speed Updated", "Farming speed set to: " .. tostring(newSpeed))
    else
        notify("Invalid Input", "Enter a valid positive number for Farming Speed.")
    end
end)
Home_Right_Menu:addToggle("Anti-AFK", false, function(state)
    AntiAFKEnabled = state
    if AntiAFKEnabled then
        disableAFK()
        task.spawn(antiAFKLoop)
        notify("Anti-AFK Enabled", "Idle kick prevention active.")
    else
        notify("Anti-AFK Disabled", "Idle kick prevention off.")
    end
end)

---------- [ SECTION: ESP TAB ]----------
local ESP_Left  = Tabs.ESP:addSection()    -- ESP for Players
local ESP_Right = Tabs.ESP:addSection()    -- ESP for Chests / Extras

local ESP_Left_Menu  = ESP_Left:addMenu("#Player ESP")
local ESP_Right_Menu = ESP_Right:addMenu("#Chest ESP / Extras")

-- Variabel untuk menyimpan referensi toggle ESP Lines
local espLinesToggle = nil

ESP_Left_Menu:addToggle('ESP Player', false, function(state)
    ESPPlayerEnabled = state

    local function AddPlayerESP(targetPlayer)
        if targetPlayer.Character and targetPlayer.Character:FindFirstChild("HumanoidRootPart") then
            local highlight = Instance.new("Highlight")
            highlight.Parent = targetPlayer.Character
            highlight.Adornee = targetPlayer.Character.HumanoidRootPart
            highlight.FillColor = Color3.fromRGB(255, 0, 0)
            highlight.FillTransparency = 0.5
            highlight.OutlineColor = Color3.fromRGB(255, 255, 255)
            highlight.OutlineTransparency = 0.5

            local billboard = Instance.new("BillboardGui")
            billboard.Parent = targetPlayer.Character
            billboard.Adornee = targetPlayer.Character.HumanoidRootPart
            billboard.Size = UDim2.new(0, 100, 0, 50)
            billboard.StudsOffset = Vector3.new(0, 3, 0)
            billboard.AlwaysOnTop = true

            local nameLabel = Instance.new("TextLabel")
            nameLabel.Parent = billboard
            nameLabel.Size = UDim2.new(1, 0, 1, 0)
            nameLabel.Text = targetPlayer.Name
            nameLabel.TextColor3 = Color3.new(1,1,1)
            nameLabel.BackgroundTransparency = 1
            nameLabel.TextStrokeTransparency = 0.5

            local distanceLabel = Instance.new("TextLabel")
            distanceLabel.Parent = billboard
            distanceLabel.Size = UDim2.new(1, 0, 0, 20)
            distanceLabel.Position = UDim2.new(0, 0, 1, 0)
            distanceLabel.TextColor3 = Color3.new(1,1,1)
            distanceLabel.BackgroundTransparency = 1
            distanceLabel.TextStrokeTransparency = 0.5

            task.spawn(function()
                while ESPPlayerEnabled and targetPlayer.Character and targetPlayer.Character:FindFirstChild("HumanoidRootPart") do
                    local dist = (targetPlayer.Character.HumanoidRootPart.Position - rootPart.Position).Magnitude
                    distanceLabel.Text = string.format("Distance: %.2f", dist)
                    if espLinesToggle and espLinesToggle.state then
                        updateESPLine(targetPlayer)
                    end
                    task.wait(1)
                end
            end)
            table.insert(PlayerHighlights, {player = targetPlayer, highlight = highlight, billboard = billboard})
        end
    end

    local function RemovePlayerESP(targetPlayer)
        for i, esp in ipairs(PlayerHighlights) do
            if esp.player == targetPlayer then
                if esp.highlight then esp.highlight:Destroy() end
                if esp.billboard then esp.billboard:Destroy() end
                table.remove(PlayerHighlights, i)
                removeESPLine(targetPlayer)
                break
            end
        end
    end

    if ESPPlayerEnabled then
        notify("ESP Player Enabled", "Player highlights and distances are now visible.")
        for _, p in ipairs(Players:GetPlayers()) do
            if p ~= player then
                AddPlayerESP(p)
            end
        end
        Players.PlayerAdded:Connect(function(p)
            if p ~= player then AddPlayerESP(p) end
        end)
        Players.PlayerRemoving:Connect(function(p) RemovePlayerESP(p) end)

        if not espLinesToggle then
            espLinesToggle = ESP_Left_Menu:addToggle("ESP Lines", false, function(lineState)
                for _, p in ipairs(Players:GetPlayers()) do
                    if p ~= player then
                        if lineState then
                            updateESPLine(p)
                        else
                            removeESPLine(p)
                        end
                    end
                end
            end)
        end
    else
        notify("ESP Player Disabled", "Player highlights and distances are now hidden.")
        for _, esp in ipairs(PlayerHighlights) do
            if esp.highlight then esp.highlight:Destroy() end
            if esp.billboard then esp.billboard:Destroy() end
        end
        PlayerHighlights = {}
        for p, _ in pairs(ESPLineObjects) do
            removeESPLine(p)
        end

        if espLinesToggle then
            Library:DestroyGui(espLinesToggle)
            espLinesToggle = nil
        end
    end
end)

ESP_Right_Menu:addToggle('ESP Chest', false, function(state)
    ESPEnabled = state
    if ESPEnabled then
        for _, v in ipairs(workspace.SandBlocks:GetChildren()) do
            if v:FindFirstChild("Chest") then
                local highlight = Instance.new("Highlight")
                highlight.Parent = v
                highlight.Adornee = v
                highlight.FillColor = Color3.fromRGB(255, 0, 0)
                highlight.FillTransparency = 0.5
                highlight.OutlineColor = Color3.fromRGB(255, 255, 255)
                highlight.OutlineTransparency = 0.5
                table.insert(ChestHighlights, highlight)
            end
        end
    else
        for _, h in ipairs(ChestHighlights) do
            h:Destroy()
        end
        ChestHighlights = {}
    end
end)

task.spawn(function()
    while true do
        if ESPEnabled then
            for _, v in ipairs(workspace.SandBlocks:GetChildren()) do
                if v:FindFirstChild("Chest") then
                    local exists = false
                    for _, h in ipairs(ChestHighlights) do
                        if h.Adornee == v then
                            exists = true
                            break
                        end
                    end
                    if not exists then
                        local highlight = Instance.new("Highlight")
                        highlight.Parent = v
                        highlight.Adornee = v
                        highlight.FillColor = Color3.fromRGB(255, 0, 0)
                        highlight.FillTransparency = 0.5
                        highlight.OutlineColor = Color3.fromRGB(255, 255, 255)
                        highlight.OutlineTransparency = 0.5
                        table.insert(ChestHighlights, highlight)
                    end
                end
            end

            for i = #ChestHighlights, 1, -1 do
                local h = ChestHighlights[i]
                if not h.Adornee or not h.Adornee.Parent then
                    h:Destroy()
                    table.remove(ChestHighlights, i)
                end
            end
        end
        task.wait(1)
    end
end)

---------- [ SECTION: TROLL TAB ]----------
local Troll_Left  = Tabs.Troll:addSection()    -- Troll Tools Section
local Troll_Right = Tabs.Troll:addSection()    -- Troll Actions Section

local Troll_Left_Menu  = Troll_Left:addMenu("#Troll")
local Troll_Right_Menu = Troll_Right:addMenu("#Actions")

-- Existing Troll Feature: Remove Tool
Troll_Left_Menu:addToggle('Remove Tool', false, function(state)
    ToolDestroyerEnabled = state
    if ToolDestroyerEnabled then
        notify("Tool Destroyer Enabled", "All tools will be removed automatically.")
        task.spawn(DestroyTools)
    else
        notify("Tool Destroyer Disabled", "Tool removal has been stopped.")
    end
end)

local joinIslandEvent = ReplicatedStorage:FindFirstChild("Events") and ReplicatedStorage.Events:FindFirstChild("JoinIsland")
if not joinIslandEvent then
    warn("JoinIsland Event not found! Ensure it exists in ReplicatedStorage.Events.")
end

Troll_Right_Menu:addToggle("Bring All Players (Instant)", _G.BringAllPlayers or false, function(value)
    _G.BringAllPlayers = value
    if _G.BringAllPlayers then
        task.spawn(function()
            local localChar = player.Character
            if localChar and localChar:FindFirstChild("HumanoidRootPart") then
                local rootPos = localChar.HumanoidRootPart.CFrame
                for _, p in ipairs(Players:GetPlayers()) do
                    if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
                        pcall(function()
                            if joinIslandEvent then
                                joinIslandEvent:FireServer(p)
                            else
                                p.Character.HumanoidRootPart.CFrame = rootPos + Vector3.new(math.random(-5,5), 0, math.random(-5,5))
                            end
                        end)
                    end
                end
            end
        end)
    end
end)

Troll_Right_Menu:addButton("Teleport to Random Player", function()
    teleportToRandomPlayer()
end)

Troll_Right_Menu:addButton("Randomize Player Positions", function()
    randomizePlayerPositions()
end)

-- === Fitur Troll Tambahan ===

-- 1. Kill All: Mematikan seluruh karakter pemain (selain lokal)
Troll_Right_Menu:addButton("Kill All", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character and p.Character:FindFirstChild("Humanoid") then
            pcall(function() p.Character:BreakJoints() end)
        end
    end
    notify("Troll", "Kill All executed!")
end)

-- 2. Explode All: Membuat ledakan di posisi setiap pemain (selain lokal)
Troll_Right_Menu:addButton("Explode All", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
            local explosion = Instance.new("Explosion")
            explosion.BlastRadius = 10
            explosion.BlastPressure = 50000
            explosion.Position = p.Character.HumanoidRootPart.Position
            explosion.Parent = workspace
        end
    end
    notify("Troll", "Explode All executed!")
end)

-- 3. Freeze All: Anchor seluruh bagian karakter pemain (selain lokal)
Troll_Right_Menu:addButton("Freeze All", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character then
            for _, part in ipairs(p.Character:GetDescendants()) do
                if part:IsA("BasePart") then
                    part.Anchored = true
                end
            end
        end
    end
    notify("Troll", "Freeze All executed!")
end)

-- 4. Unfreeze All: Lepaskan anchor dari seluruh bagian karakter pemain (selain lokal)
Troll_Right_Menu:addButton("Unfreeze All", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character then
            for _, part in ipairs(p.Character:GetDescendants()) do
                if part:IsA("BasePart") then
                    part.Anchored = false
                end
            end
        end
    end
    notify("Troll", "Unfreeze All executed!")
end)

-- 5. Teleport All to Local: Teleport semua pemain (selain lokal) ke posisi pemain lokal
Troll_Right_Menu:addButton("Teleport All to Local", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
            p.Character.HumanoidRootPart.CFrame = rootPart.CFrame + Vector3.new(math.random(-3,3), 0, math.random(-3,3))
        end
    end
    notify("Troll", "Teleport All to Local executed!")
end)

-- 6. Teleport All to Random: Teleport semua pemain (selain lokal) ke lokasi acak
Troll_Right_Menu:addButton("Teleport All to Random", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
            p.Character.HumanoidRootPart.CFrame = CFrame.new(math.random(-500,500), 10, math.random(-500,500))
        end
    end
    notify("Troll", "Teleport All to Random executed!")
end)

-- 7. Swap All Positions: Tukar posisi antara semua pemain (selain lokal) secara acak
Troll_Right_Menu:addButton("Swap All Positions", function()
    local positions = {}
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
            table.insert(positions, p.Character.HumanoidRootPart.CFrame)
        end
    end
    for i, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") and positions[i] then
            p.Character.HumanoidRootPart.CFrame = positions[i]
        end
    end
    notify("Troll", "Swap All Positions executed!")
end)

-- 8. Set Gravity Low: Mengatur gravitasi workspace menjadi rendah
Troll_Right_Menu:addButton("Set Gravity Low", function()
    workspace.Gravity = 10
    notify("Troll", "Gravity set to low!")
end)

-- 9. Set Gravity High: Mengatur gravitasi workspace menjadi tinggi
Troll_Right_Menu:addButton("Set Gravity High", function()
    workspace.Gravity = 300
    notify("Troll", "Gravity set to high!")
end)

-- 10. Force Dance All: Memaksa semua pemain (selain lokal) berputar seolah-olah berdansa selama 5 detik
Troll_Right_Menu:addButton("Force Dance All", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
            spawn(function()
                local duration = 5
                local startTime = tick()
                while tick() - startTime < duration do
                    p.Character.HumanoidRootPart.CFrame = p.Character.HumanoidRootPart.CFrame * CFrame.Angles(0, math.rad(20), 0)
                    task.wait(0.1)
                end
            end)
        end
    end
    notify("Troll", "Force Dance All executed!")
end)

-- 11. Rename All Players: Ubah nama tampilan semua pemain (selain lokal)
Troll_Right_Menu:addButton("Rename All Players", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player then
            p.DisplayName = "Trolled!"
        end
    end
    notify("Troll", "Rename All Players executed!")
end)

-- 12. Spawn Bricks Rain: Hujan bata di atas kepala semua pemain (selain lokal)
Troll_Right_Menu:addButton("Spawn Bricks Rain", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
            for i = 1, 5 do
                local brick = Instance.new("Part")
                brick.Size = Vector3.new(4,1,4)
                brick.Position = p.Character.HumanoidRootPart.Position + Vector3.new(math.random(-3,3), 50, math.random(-3,3))
                brick.Anchored = false
                brick.Parent = workspace
                game.Debris:AddItem(brick, 5)
            end
        end
    end
    notify("Troll", "Spawn Bricks Rain executed!")
end)

-- 13. Spin All Players: Putar semua pemain (selain lokal) selama 5 detik
Troll_Right_Menu:addButton("Spin All Players", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
            spawn(function()
                local duration = 5
                local startTime = tick()
                while tick() - startTime < duration do
                    p.Character.HumanoidRootPart.CFrame = p.Character.HumanoidRootPart.CFrame * CFrame.Angles(0, math.rad(30), 0)
                    task.wait(0.1)
                end
            end)
        end
    end
    notify("Troll", "Spin All Players executed!")
end)

-- 14. Fake Server Crash: Buat ledakan secara berulang di sekitar pemain lokal selama 3 detik
Troll_Right_Menu:addButton("Fake Server Crash", function()
    spawn(function()
        local duration = 3
        local startTime = tick()
        while tick() - startTime < duration do
            local explosion = Instance.new("Explosion")
            explosion.BlastRadius = 15
            explosion.BlastPressure = 100000
            explosion.Position = rootPart.Position + Vector3.new(math.random(-5,5), 0, math.random(-5,5))
            explosion.Parent = workspace
            task.wait(0.2)
        end
    end)
    notify("Troll", "Fake Server Crash executed!")
end)

-- 15. Color All Players: Ubah warna semua bagian karakter pemain (selain lokal) ke warna acak
Troll_Right_Menu:addButton("Color All Players", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character then
            for _, part in ipairs(p.Character:GetDescendants()) do
                if part:IsA("BasePart") then
                    part.BrickColor = BrickColor.Random()
                end
            end
        end
    end
    notify("Troll", "Color All Players executed!")
end)

-- 16. Anchor All Players: Anchor seluruh bagian karakter pemain (selain lokal)
Troll_Right_Menu:addButton("Anchor All Players", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character then
            for _, part in ipairs(p.Character:GetDescendants()) do
                if part:IsA("BasePart") then
                    part.Anchored = true
                end
            end
        end
    end
    notify("Troll", "Anchor All Players executed!")
end)

-- 17. Explode Self: Buat ledakan pada karakter pemain lokal
Troll_Right_Menu:addButton("Explode Self", function()
    if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
        local explosion = Instance.new("Explosion")
        explosion.BlastRadius = 10
        explosion.BlastPressure = 50000
        explosion.Position = player.Character.HumanoidRootPart.Position
        explosion.Parent = workspace
        notify("Troll", "Explode Self executed!")
    end
end)

-- 18. Chain Lightning: Buat rangkaian ledakan ke pemain terdekat secara berantai
Troll_Right_Menu:addButton("Chain Lightning", function()
    local function getNearestPlayer(fromPos)
        local nearest, minDist = nil, math.huge
        for _, p in ipairs(Players:GetPlayers()) do
            if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
                local dist = (p.Character.HumanoidRootPart.Position - fromPos).Magnitude
                if dist < minDist then
                    minDist = dist
                    nearest = p
                end
            end
        end
        return nearest
    end

    local currentPos = rootPart.Position
    for i = 1, 5 do
        local target = getNearestPlayer(currentPos)
        if target and target.Character and target.Character:FindFirstChild("HumanoidRootPart") then
            local explosion = Instance.new("Explosion")
            explosion.BlastRadius = 8
            explosion.BlastPressure = 80000
            explosion.Position = target.Character.HumanoidRootPart.Position
            explosion.Parent = workspace
            currentPos = target.Character.HumanoidRootPart.Position
            task.wait(0.5)
        else
            break
        end
    end
    notify("Troll", "Chain Lightning executed!")
end)

-- 19. Force Respawn All: Memaksa semua pemain (selain lokal) respawn
Troll_Right_Menu:addButton("Force Respawn All", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character then
            p.Character:BreakJoints()
        end
    end
    notify("Troll", "Force Respawn All executed!")
end)

-- 20. Spin Self: Putar karakter pemain lokal selama 5 detik
Troll_Right_Menu:addButton("Spin Self", function()
    if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
        local duration = 5
        local startTime = tick()
        while tick() - startTime < duration do
            player.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.Angles(0, math.rad(30), 0)
            task.wait(0.1)
        end
        notify("Troll", "Spin Self executed!")
    end
end)

-- 21. Random Freeze All: Secara acak anchor sebagian bagian dari karakter pemain (selain lokal)
Troll_Right_Menu:addButton("Random Freeze All", function()
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= player and p.Character then
            for _, part in ipairs(p.Character:GetDescendants()) do
                if part:IsA("BasePart") then
                    part.Anchored = (math.random() < 0.5)
                end
            end
        end
    end
    notify("Troll", "Random Freeze All executed!")
end)

---------- [ SECTION: TOOLS TAB ]----------
local Tools_Left  = Tabs.Tools:addSection()    -- Primary Tools Section
local Main_Tools  = Tools_Left:addMenu("#Tools")
local Tools_Right = Tabs.Tools:addSection()    -- Extra Tools Section
local Extra_Tools = Tools_Right:addMenu("#Extra Tools")

Main_Tools:addButton("Reset Character", function()
    if player.Character then
        player.Character:BreakJoints()
        notify("Reset Character", "Character will respawn shortly.")
    end
end)

--[[. Infinite Yield
local BjK = loadstring(game:HttpGet('https://raw.githubusercontent.com/DarkNetworks/Infinite-Yield/main/latest.lua'))() ]

Main_Tools:addButton('Infinite Yield', false, function(state)
    IY = state
    if IY then
       notify("Actived", "Infinite Yield")
       task.spawn(BjK)
    else
       print("Deactive", "Infinite Yield")
    end
end)
--]]

Main_Tools:addButton("Teleport to Cursor", function()
    if mouse and rootPart then
        local targetPos = mouse.Hit.p
        rootPart.CFrame = CFrame.new(targetPos)
        notify("Teleport", "Teleported to cursor position.")
    end
end)

Main_Tools:addButton("Teleport to Random Location", function()
    teleportToRandomLocation()
end)

Extra_Tools:addTextbox("Set Walk Speed", tostring(BaseWalkSpeed), function(value)
    local newSpeed = tonumber(value)
    if newSpeed and newSpeed > 0 then
        BaseWalkSpeed = newSpeed
        if SpeedBoostEnabled then
            humanoid.WalkSpeed = BaseWalkSpeed * SpeedBoostMultiplier
        else
            humanoid.WalkSpeed = BaseWalkSpeed
        end
        notify("Walk Speed", "Walk speed set to " .. tostring(newSpeed))
    else
        notify("Invalid Input", "Enter a valid positive number for Walk Speed.")
    end
end)

Extra_Tools:addToggle("Infinite Jump", false, function(state)
    InfiniteJumpEnabled = state
    notify("Infinite Jump", state and "Infinite Jump enabled." or "Infinite Jump disabled.")
end)
UserInputService.JumpRequest:Connect(function()
    if InfiniteJumpEnabled then
        if humanoid then
            humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
        end
    end
end)

Extra_Tools:addToggle("Fly Mode", false, function(state)
    FlyEnabled = state
    if FlyEnabled then
        notify("Fly Mode", "Fly mode enabled. Press [E] to ascend, [Q] to descend.")
    else
        notify("Fly Mode", "Fly mode disabled.")
    end
end)
Extra_Tools:addTextbox("Set Fly Speed", tostring(FlySpeed), function(value)
    local newFlySpeed = tonumber(value)
    if newFlySpeed and newFlySpeed > 0 then
        FlySpeed = newFlySpeed
        notify("Fly Speed", "Fly speed set to " .. tostring(newFlySpeed))
    else
        notify("Invalid Input", "Enter a valid positive number for Fly Speed.")
    end
end)

local flying = false
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if FlyEnabled then
        if input.KeyCode == Enum.KeyCode.E then
            flying = "ascend"
        elseif input.KeyCode == Enum.KeyCode.Q then
            flying = "descend"
        end
    end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if FlyEnabled and (input.KeyCode == Enum.KeyCode.E or input.KeyCode == Enum.KeyCode.Q) then
        flying = false
    end
end)
RunService.RenderStepped:Connect(function(delta)
    if FlyEnabled and flying and rootPart then
        local newPos = rootPart.Position
        if flying == "ascend" then
            newPos = newPos + Vector3.new(0, FlySpeed * delta, 0)
        elseif flying == "descend" then
            newPos = newPos - Vector3.new(0, FlySpeed * delta, 0)
        end
        rootPart.CFrame = CFrame.new(newPos)
    end
end)

Extra_Tools:addToggle("Speed Boost", false, function(state)
    SpeedBoostEnabled = state
    if SpeedBoostEnabled then
        humanoid.WalkSpeed = BaseWalkSpeed * SpeedBoostMultiplier
        notify("Speed Boost", "Speed Boost enabled.")
    else
        humanoid.WalkSpeed = BaseWalkSpeed
        notify("Speed Boost", "Speed Boost disabled.")
    end
end)
Extra_Tools:addTextbox("Boost Multiplier", tostring(SpeedBoostMultiplier), function(value)
    local newMultiplier = tonumber(value)
    if newMultiplier and newMultiplier > 0 then
        SpeedBoostMultiplier = newMultiplier
        if SpeedBoostEnabled then
            humanoid.WalkSpeed = BaseWalkSpeed * SpeedBoostMultiplier
        end
        notify("Boost Multiplier", "Boost multiplier set to " .. tostring(newMultiplier))
    else
        notify("Invalid Input", "Enter a valid positive number for Boost Multiplier.")
    end
end)

Extra_Tools:addToggle("God Mode", false, function(state)
    GodModeEnabled = state
    if GodModeEnabled then
        notify("God Mode", "God Mode enabled.")
        enableGodMode()
    else
        notify("God Mode", "God Mode disabled.")
    end
end)

Extra_Tools:addToggle("Invisible Mode", false, function(state)
    InvisibleEnabled = state
    setInvisible(InvisibleEnabled)
    notify("Invisible Mode", state and "You are now invisible." or "You are now visible.")
end)

-- New Feature: NoClip
Extra_Tools:addToggle("NoClip", false, function(state)
    NoclipEnabled = state
    if NoclipEnabled then
        notify("NoClip", "NoClip enabled. You can pass through walls.")
    else
        notify("NoClip", "NoClip disabled.")
    end
end)
RunService.RenderStepped:Connect(function()
    if NoclipEnabled and character then
        for _, part in ipairs(character:GetDescendants()) do
            if part:IsA("BasePart") then
                part.CanCollide = false
            end
        end
    end
end)

---------- [ End of Script ]----------
notify("Loaded", "JustShare Hub Advanced Pro loaded successfully. Enjoy!")