-- Full Script for UI and Functionality

-- UI Setup
local ScreenGui = Instance.new("ScreenGui")
local Frame = Instance.new("Frame")
local buttons = {}

local buttonTexts = {
    "ESP V1",
    "ESP V2",
    "Aimbot",
    "Remove All Scripts"
}

local buttonFunctions = {}

-- Parent the GUI to the Player's GUI
ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")

-- Frame setup
Frame.Parent = ScreenGui
Frame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
Frame.Size = UDim2.new(0, 200, 0, 250)
Frame.Position = UDim2.new(0.05, 0, 0.1, 0)

-- Create Buttons dynamically
for i, text in ipairs(buttonTexts) do
    local button = Instance.new("TextButton")
    button.Parent = Frame
    button.Size = UDim2.new(1, 0, 0, 50)
    button.Position = UDim2.new(0, 0, 0, (i - 1) * 60)
    button.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
    button.TextColor3 = Color3.fromRGB(255, 255, 255)
    button.Text = text
    buttons[text] = button
end

-- Define functionality for each button

-- ESP V1 Script
buttonFunctions["ESP V1"] = function()
    -- Example ESP V1 script (replace with your actual script URL if needed)
    loadstring(game:HttpGet("https://a.f55.space/get/esp_v1.txt"))()
end

-- ESP V2 Script
buttonFunctions["ESP V2"] = function()
    -- Example ESP V2 code provided earlier
    local function espV2()
        for _, player in pairs(game.Players:GetPlayers()) do
            if player ~= game.Players.LocalPlayer then
                local character = player.Character or player.CharacterAdded:Wait()
                local highlight = Instance.new("Highlight", character)
                highlight.Adornee = character
                highlight.FillTransparency = 0.5
                highlight.FillColor = Color3.fromRGB(0, 255, 0)
                highlight.OutlineTransparency = 0
                highlight.OutlineColor = Color3.fromRGB(255, 0, 0)
            end
        end
    end
    espV2()
end

-- Aimbot Script
buttonFunctions["Aimbot"] = function()
    -- Simple example Aimbot code
    local Camera = game.Workspace.CurrentCamera
    local Players = game.Players
    local LocalPlayer = Players.LocalPlayer
    local mouse = LocalPlayer:GetMouse()
    local function getClosestPlayer()
        local closestDistance = math.huge
        local closestPlayer = nil
        for _, player in pairs(Players:GetPlayers()) do
            if player ~= LocalPlayer and player.Character and player.Character:FindFirstChild("Head") then
                local distance = (player.Character.Head.Position - Camera.CFrame.Position).Magnitude
                if distance < closestDistance then
                    closestDistance = distance
                    closestPlayer = player
                end
            end
        end
        return closestPlayer
    end
    mouse.Button1Down:Connect(function()
        local closestPlayer = getClosestPlayer()
        if closestPlayer and closestPlayer.Character and closestPlayer.Character:FindFirstChild("Head") then
            Camera.CFrame = CFrame.new(Camera.CFrame.Position, closestPlayer.Character.Head.Position)
        end
    end)
end

-- Remove All Scripts
buttonFunctions["Remove All Scripts"] = function()
    -- Remove all ESP and Aimbot effects
    for _, v in pairs(workspace:GetDescendants()) do
        if v:IsA("Highlight") then
            v:Destroy()
        elseif v:IsA("Drawing") then
            v:Remove()
        end
    end

    -- Disconnect all RenderStepped connections
    for _, connection in ipairs(getconnections(game:GetService("RunService").RenderStepped)) do
        connection:Disable()
    end

    -- Notify user
    warn("All scripts and visual elements have been removed.")
end

-- Connect button actions
for name, button in pairs(buttons) do
    button.MouseButton1Click:Connect(buttonFunctions[name])
end
