Загрузка данных


local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

-- ═══════════════════════════════════════
-- СОЗДАНИЕ GUI
-- ═══════════════════════════════════════
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "AutoKillToggle"
screenGui.ResetOnSpawn = false
screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
screenGui.Parent = playerGui

local mainFrame = Instance.new("Frame")
mainFrame.Name = "MainFrame"
mainFrame.Size = UDim2.new(0, 220, 0, 90)
mainFrame.Position = UDim2.new(0, 20, 0, 20)
mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
mainFrame.BorderSizePixel = 0
mainFrame.Active = true
mainFrame.Draggable = true
mainFrame.Parent = screenGui

Instance.new("UICorner", mainFrame).CornerRadius = UDim.new(0, 10)

local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, 0, 0, 25)
title.Position = UDim2.new(0, 0, 0, 5)
title.BackgroundTransparency = 1
title.Text = "Auto Kill"
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.Font = Enum.Font.GothamBold
title.TextSize = 16
title.Parent = mainFrame

local toggleBtn = Instance.new("TextButton")
toggleBtn.Name = "Toggle"
toggleBtn.Size = UDim2.new(0, 190, 0, 45)
toggleBtn.Position = UDim2.new(0, 15, 0, 35)
toggleBtn.Text = "ВЫКЛ"
toggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
toggleBtn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
toggleBtn.Font = Enum.Font.GothamBold
toggleBtn.TextSize = 18
toggleBtn.AutoButtonColor = true
toggleBtn.Parent = mainFrame

Instance.new("UICorner", toggleBtn).CornerRadius = UDim.new(0, 8)

-- ═══════════════════════════════════════
-- ЛОГИКА
-- ═══════════════════════════════════════
local isActive = false
local charConnection = nil

local function killChar(char)
    local hum = char:WaitForChild("Humanoid", 3)
    if hum then
        hum.Health = 0
    end
end

local function setState(active)
    isActive = active
    
    if isActive then
        toggleBtn.Text = "ВКЛ"
        toggleBtn.BackgroundColor3 = Color3.fromRGB(50, 180, 80)
        
        -- Убиваем текущего персонажа сразу
        if player.Character then
            task.spawn(killChar, player.Character)
        end
        
        -- Подключаем авто-убийство при респавне
        charConnection = player.CharacterAdded:Connect(killChar)
    else
        toggleBtn.Text = "ВЫКЛ"
        toggleBtn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
        
        -- Отключаем
        if charConnection then
            charConnection:Disconnect()
            charConnection = nil
        end
    end
end

toggleBtn.MouseButton1Click:Connect(function()
    setState(not isActive)
end)

-- Клавиша для быстрого переключения (RightShift)
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input, gpe)
    if gpe then return end
    if input.KeyCode == Enum.KeyCode.RightShift then
        screenGui.Enabled = not screenGui.Enabled
    end
end)