게임 인증코드

게임 안에서 코드를 입력하면 그 게임 서버가 로블록스 계정을 확인해 디스코드와 연결합니다. 스튜디오에서 입력창과 채팅 명령을 붙이는 방법을 그대로 붙여 쓸 수 있는 예제로 정리했습니다.

이 방식은 이렇게 동작합니다#

이용자는 디스코드에서 /연동 을 방식:게임 코드 로 실행해 15분짜리 1회용 코드(BS-XXXXXXXX)를 받습니다. 게임 서버는 그 코드와 플레이어의 로블록스 ID를 BaseSeal 에 보내고, 코드가 맞으면 연결이 확정되면서 디스코드 역할이 자동으로 지급됩니다. 프로필 소개글을 고칠 필요가 없어서, 게임 화면에서 바로 인증하게 하고 싶을 때 가장 간단합니다.

  1. 코드 받기이용자가 디스코드에서 /연동 방식:게임 코드 를 실행합니다. 코드는 15분 뒤 만료되고 한 번만 쓸 수 있습니다.
  2. 게임에서 입력게임 화면의 입력창이나 /인증 <코드> 채팅 명령으로 코드를 넣습니다.
  3. 게임 서버가 확인게임 서버(서버 스크립트)가 코드와 플레이어 ID를 BaseSeal 에 보내 검증합니다. 게임 서버 키가 필요합니다.
  4. 연결 확정일치하면 디스코드 계정과 로블록스 계정이 연결되고 역할이 지급됩니다. 다음 입장 판정부터 새 상태가 적용됩니다.

스튜디오 준비물#

준비물어디서
게임 서버 키CONDERI 운영자가 발급합니다. 디스코드 /게이트키 로 본인에게만 표시됩니다
유니버스 ID스튜디오 Game Settings → Basic Info 의 Universe ID
HTTP 요청 허용Game Settings → Security → Allow HTTP Requests 켜기
게이트 모듈BaseSealGate ModuleScript 를 ReplicatedStorage → Modules 아래에 넣기
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BaseSeal = require(ReplicatedStorage.Modules.BaseSealGate)

BaseSeal.configure({
    endpoint = "https://base.conderi.com",   -- BaseSeal 서버 주소
    universeId = "<이 게임의 유니버스 ID>",
    gameServerKey = "<게임 서버 키>",       -- 서버 스크립트에서만 사용
    failClosed = true,                     -- 응답을 못 받으면 입장 거부
})

예시 1 — 화면 입력창(ScreenGui)으로 받기#

가장 많이 쓰는 형태입니다. 화면 오른쪽 아래에 인증 코드 입력 버튼이 생기고, 버튼을 누르면 입력창이 뜹니다. 입력한 코드는 RemoteFunction 으로 서버에 넘어가고, 결과는 같은 화면에 표시됩니다. 아래 두 스크립트만 넣으면 되고, 따로 UI 를 만들 필요가 없습니다.

① 서버 스크립트 (ServerScriptService)#

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BaseSeal = require(ReplicatedStorage.Modules.BaseSealGate)

BaseSeal.configure({
    endpoint = "https://base.conderi.com",
    universeId = "<이 게임의 유니버스 ID>",
    gameServerKey = "<게임 서버 키>",
    failClosed = true,
})

-- Remotes 폴더와 RemoteFunction 이 없으면 만든다
local remotes = ReplicatedStorage:FindFirstChild("Remotes")
if not remotes then
    remotes = Instance.new("Folder")
    remotes.Name = "Remotes"
    remotes.Parent = ReplicatedStorage
end
local verify = remotes:FindFirstChild("BaseSealVerify")
if not verify then
    verify = Instance.new("RemoteFunction")
    verify.Name = "BaseSealVerify"
    verify.Parent = remotes
end

local COOLDOWN = 5      -- 같은 플레이어가 5초에 한 번만 시도
local lastTry = {}

verify.OnServerInvoke = function(player, code)
    if typeof(code) ~= "string" then
        return false, "인증 코드를 입력해 주세요."
    end
    code = string.upper((string.gsub(code, "%s", "")))
    if #code < 6 then
        return false, "인증 코드 형식이 올바르지 않습니다."
    end
    local now = os.clock()
    if lastTry[player.UserId] and (now - lastTry[player.UserId]) < COOLDOWN then
        return false, "잠시 후 다시 시도해 주세요."
    end
    lastTry[player.UserId] = now
    local ok, message = BaseSeal:VerifyCode(player.UserId, code)
    if ok then
        BaseSeal.clearCache(player.UserId)   -- 다음 입장 판정을 새로 받는다
    end
    return ok, message
end

② 화면 스크립트 (StarterPlayer → StarterPlayerScripts)#

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local verify = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("BaseSealVerify")

local gui = Instance.new("ScreenGui")
gui.Name = "BaseSealVerifyUI"
gui.ResetOnSpawn = false
gui.Parent = player:WaitForChild("PlayerGui")

local openButton = Instance.new("TextButton")
openButton.Name = "Open"
openButton.Size = UDim2.fromOffset(150, 40)
openButton.Position = UDim2.new(1, -170, 1, -60)
openButton.Text = "인증 코드 입력"
openButton.TextSize = 16
openButton.BackgroundColor3 = Color3.fromRGB(31, 78, 156)
openButton.TextColor3 = Color3.new(1, 1, 1)
openButton.Parent = gui

local panel = Instance.new("Frame")
panel.Name = "Panel"
panel.Size = UDim2.fromOffset(320, 150)
panel.Position = UDim2.new(0.5, 0, 0.4, 0)
panel.AnchorPoint = Vector2.new(0.5, 0.5)
panel.BackgroundColor3 = Color3.fromRGB(20, 24, 33)
panel.BorderSizePixel = 0
panel.Visible = false
panel.Parent = gui

local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, -24, 0, 24)
title.Position = UDim2.fromOffset(12, 10)
title.BackgroundTransparency = 1
title.Font = Enum.Font.GothamBold
title.TextSize = 16
title.TextColor3 = Color3.new(1, 1, 1)
title.TextXAlignment = Enum.TextXAlignment.Left
title.Text = "디스코드에서 받은 코드를 입력하세요"
title.Parent = panel

local box = Instance.new("TextBox")
box.Size = UDim2.new(1, -24, 0, 34)
box.Position = UDim2.fromOffset(12, 42)
box.BackgroundColor3 = Color3.fromRGB(32, 38, 50)
box.TextColor3 = Color3.new(1, 1, 1)
box.PlaceholderText = "BS-XXXXXXXX"
box.Text = ""
box.ClearTextOnFocus = false
box.Parent = panel

local submit = Instance.new("TextButton")
submit.Size = UDim2.fromOffset(120, 32)
submit.Position = UDim2.fromOffset(12, 86)
submit.Text = "확인"
submit.Parent = panel

local close = Instance.new("TextButton")
close.Size = UDim2.fromOffset(120, 32)
close.Position = UDim2.fromOffset(150, 86)
close.Text = "닫기"
close.Parent = panel

local result = Instance.new("TextLabel")
result.Size = UDim2.new(1, -24, 0, 28)
result.Position = UDim2.fromOffset(12, 120)
result.BackgroundTransparency = 1
result.TextSize = 13
result.TextWrapped = true
result.TextColor3 = Color3.fromRGB(180, 190, 205)
result.Text = ""
result.Parent = panel

openButton.Activated:Connect(function()
    panel.Visible = true
    box:CaptureFocus()
end)

close.Activated:Connect(function()
    panel.Visible = false
    result.Text = ""
end)

submit.Activated:Connect(function()
    local code = box.Text
    if code == "" then
        result.Text = "코드를 입력해 주세요."
        return
    end
    result.Text = "확인 중..."
    local ok, message = verify:InvokeServer(code)
    result.Text = message or ""
    result.TextColor3 = ok and Color3.fromRGB(120, 220, 160)
        or Color3.fromRGB(240, 140, 140)
    if ok then
        box.Text = ""
    end
end)

예시 2 — 채팅 명령(/인증 코드)으로 받기#

UI 를 만들지 않고 채팅으로만 받고 싶다면 아래처럼 Player.Chatted 를 사용합니다. 서버 스크립트에 넣으면 플레이어가 /인증 BS-ABCD2345 처럼 입력했을 때 검증합니다.

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BaseSeal = require(ReplicatedStorage.Modules.BaseSealGate)

-- 위 예시의 스크립트가 configure() 와 Remotes 생성까지 했다고 가정합니다.
local toast = ReplicatedStorage:WaitForChild("Remotes"):FindFirstChild("BaseSealToast")

Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        local code = string.match(message, "^/인증%s+(.+)$")
        if not code then
            return
        end
        code = string.upper((string.gsub(code, "%s", "")))
        local ok, reason = BaseSeal:VerifyCode(player.UserId, code)
        if ok then
            BaseSeal.clearCache(player.UserId)
        end
        local text = ok and "인증이 완료되었습니다. 디스코드 역할이 지급됩니다."
            or tostring(reason or "인증하지 못했습니다.")
        if toast then
            toast:FireClient(player, text)
        else
            print("[BaseSeal] " .. player.Name .. ": " .. text)
        end
    end)
end)

채팅 결과를 화면에 띄우려면 RemoteEvent 하나를 두고 클라이언트에서 짧게 표시하면 됩니다.

-- ServerScriptService: RemoteEvent 생성 (한 번만)
local remotes = game:GetService("ReplicatedStorage"):FindFirstChild("Remotes")
if remotes and not remotes:FindFirstChild("BaseSealToast") then
    local ev = Instance.new("RemoteEvent")
    ev.Name = "BaseSealToast"
    ev.Parent = remotes
end

-- StarterPlayerScripts: 결과를 3초 동안 화면에 표시
local player = game:GetService("Players").LocalPlayer
local toast = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("BaseSealToast")
local gui = Instance.new("ScreenGui")
gui.ResetOnSpawn = false
gui.Parent = player:WaitForChild("PlayerGui")
local label = Instance.new("TextLabel")
label.Size = UDim2.new(1, -120, 0, 36)
label.Position = UDim2.new(0, 60, 0, 80)
label.BackgroundColor3 = Color3.fromRGB(20, 24, 33)
label.BackgroundTransparency = 0.1
label.TextColor3 = Color3.new(1, 1, 1)
label.TextSize = 15
label.Visible = false
label.Parent = gui

toast.OnClientEvent:Connect(function(text)
    label.Text = text
    label.Visible = true
    task.delay(3, function()
        label.Visible = false
    end)
end)

예시 3 — 입장 판정과 함께 쓰기#

인증을 마친 사람만 들이는 게임이라면, 입장 판정(CheckPlayer)과 인증(VerifyCode)을 함께 두면 됩니다. 인증 직후 캐시를 비우므로 다음 판정부터 바로 통과합니다.

game.Players.PlayerAdded:Connect(function(player)
    local verdict = BaseSeal:CheckPlayer(player.UserId)
    if not verdict.allow then
        -- 미인증이면 바로 내보내지 않고 인증 화면을 먼저 보여 줄 수도 있습니다.
        player:Kick("CONDERI BaseSeal: " .. verdict.message)
    end
end)

결과 메시지 읽기#

결과의미이용자가 할 일
인증 완료코드가 맞아 연결이 확정됨디스코드에서 역할이 붙었는지 확인
인증 코드를 찾을 수 없습니다코드를 잘못 입력했거나 다른 서버에서 발급/연동 으로 받은 코드를 그대로 입력
인증 코드가 만료되었습니다발급 후 15분이 지남/연동 을 다시 실행해 새 코드 발급
이미 사용된 코드입니다한 번 쓴 코드를 다시 입력/연동 으로 새 코드 발급
발급받은 계정과 다릅니다코드를 받은 디스코드 계정의 로블록스 계정과 현재 플레이어가 다름본인 계정으로 다시 실행
인증이 제한된 계정입니다차단 목록에 등재된 계정/이의제기 로 재심사 요청
이미 연결된 계정입니다다른 디스코드 계정과 이미 연결됨/연동해제 후 다시 시도
인증 서버에 연결하지 못했습니다게임 서버의 HTTP 허용·키·주소 설정 문제게임 개발자에게 설정 확인 요청
잠시 후 다시 시도해 주세요짧은 시간에 너무 많이 시도(레이트리밋)10~20초 뒤 다시 시도

운영 팁#

  • 코드는 15분·1회용입니다. 이용자에게는 연동 직후 바로 입력하도록 안내하는 것이 좋습니다.
  • 게임 서버 키는 서버 스크립트에만 두고, 노출이 의심되면 운영자에게 재발급을 요청하세요.
  • 같은 코드로 여러 번 시도하는 경우는 대부분 만료입니다. 안내 문구에 재발급 방법을 함께 적어 두세요.
  • 인증 직후 BaseSeal.clearCache(userId) 를 호출하면 다음 입장 판정에 바로 반영됩니다.