Simple key system

Simple key system
Lua
local ScreenGui = Instance.new("ScreenGui")
local Frame = Instance.new("Frame")
local UICorner = Instance.new("UICorner")
local KeyInput = Instance.new("TextBox")
local SubmitButton = Instance.new("TextButton")
local CopyKeyButton = Instance.new("TextButton")
local StatusLabel = Instance.new("TextLabel")
local CreditLabel = Instance.new("TextLabel")
local LoadingFrame = Instance.new("Frame")
local LoadingLabel = Instance.new("TextLabel")

local Dragging = false
local DragInput, DragStart, StartPos

ScreenGui.Parent = game.CoreGui

Frame.Parent = ScreenGui
Frame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
Frame.Size = UDim2.new(0, 300, 0, 230)
Frame.Position = UDim2.new(0.5, -150, 0.5, -115)
Frame.Active = true

UICorner.Parent = Frame
UICorner.CornerRadius = UDim.new(0, 10)

KeyInput.Parent = Frame
KeyInput.Size = UDim2.new(0.8, 0, 0.15, 0)
KeyInput.Position = UDim2.new(0.1, 0, 0.2, 0)
KeyInput.PlaceholderText = "Введите ключ"
KeyInput.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
KeyInput.TextColor3 = Color3.fromRGB(255, 255, 255)

SubmitButton.Parent = Frame
SubmitButton.Size = UDim2.new(0.8, 0, 0.15, 0)
SubmitButton.Position = UDim2.new(0.1, 0, 0.4, 0)
SubmitButton.Text = "Проверить ключ"
SubmitButton.BackgroundColor3 = Color3.fromRGB(255, 0, 255)

CopyKeyButton.Parent = Frame
CopyKeyButton.Size = UDim2.new(0.8, 0, 0.15, 0)
CopyKeyButton.Position = UDim2.new(0.1, 0, 0.6, 0)
CopyKeyButton.Text = "Скопировать ссылку"
CopyKeyButton.BackgroundColor3 = Color3.fromRGB(0, 255, 255)

StatusLabel.Parent = Frame
StatusLabel.Size = UDim2.new(0.8, 0, 0.1, 0)
StatusLabel.Position = UDim2.new(0.1, 0, 0.05, 0)
StatusLabel.Text = "Введите свой ключ"
StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 0)

LoadingFrame.Parent = ScreenGui
LoadingFrame.Size = UDim2.new(1, 0, 1, 0)
LoadingFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
LoadingFrame.Visible = false 

LoadingLabel.Parent = LoadingFrame
LoadingLabel.Size = UDim2.new(1, 0, 1, 0)
LoadingLabel.Text = "Загрузка скрипта, пожалуйста, подождите..."
LoadingLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
LoadingLabel.TextScaled = true
LoadingLabel.BackgroundTransparency = 1

local fileName = "keys.txt"
local correctKey = "ItzPerson"
local scriptURL = "https://raw.githubusercontent.com/1itzperson/scripts/refs/heads/main/Teleport%20to%20player.lua"
local keyLink = "https://itzperson.ru/fordevelopers/" 

local function fileExists(file)
    local success, response = pcall(function() return readfile(file) end)
    return success and response ~= nil
end

local function saveKey(key)
    writefile(fileName, key)
end

local function loadKey()
    if fileExists(fileName) then
        return readfile(fileName)
    else
        return nil
    end
end

local savedKey = loadKey()
if savedKey then
    KeyInput.Text = savedKey
end

SubmitButton.MouseButton1Click:Connect(function()
    if KeyInput.Text == correctKey then
        StatusLabel.Text = "Доступ разрешен!"
        StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
        saveKey(KeyInput.Text)
        
        Frame.Visible = false
        LoadingFrame.Visible = true
        task.wait(2.5)
        
        local success, result = pcall(function()
            return loadstring(game:HttpGet(scriptURL, true))()
        end)
        
        if not success then
            StatusLabel.Text = "Ошибка загрузки скрипта"
            warn("Ошибка: " .. result)
        end
        
        LoadingFrame.Visible = false
    else
        StatusLabel.Text = "Неправильный ключ!"
        StatusLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
    end
end)

CopyKeyButton.MouseButton1Click:Connect(function()
    if setclipboard then
        setclipboard(keyLink)
        StatusLabel.Text = "Ссылка скопирована!"
        StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 255)
    else
        StatusLabel.Text = "Буфер обмена не поддерживается!"
    end
end)