Script API

What this is: Inside a protected script, a global LuaProtect table gives you what the server knows about the player running it: who they are, their key, their Discord link, and numbers about your script. Read a field like any other value: LuaProtect.Key.Note, LuaProtect.User.Username, LuaProtect.Script.Executions.

The namespaces

NamespaceWhat it holds
LuaProtect.UserThe Roblox player: username, user id, executor, how often they ran this script.
LuaProtect.KeyThe license key locked to this device: note, expiry, time left, HWID lock, uses.
LuaProtect.DiscordThe Discord account linked to the player, and your server invite.
LuaProtect.ScriptThe script itself: name, version and execution totals.
LuaProtect.SessionThis run: session id, when it started and how it is connected.
LuaProtect.StorageLive data and per-player saves. See Data storage.
LuaProtect.FeedbackStar ratings from inside the game. See Player reviews.
LuaProtect.ThemeThe values the owner set in the Style tab, so a window you draw can match the key prompt and review card.

LuaProtect.User

FieldTypeValue
UsernamestringThe Roblox username.
UserIdnumberThe Roblox user id.
ExecutionsnumberHow many times this player has run this script.
ExecutorstringThe executor the runner detected.
FingerprintstringA short, one-way code of the device. The real HWID is never sent to the script.

LuaProtect.Key

The key is found from the verified device, so a script cannot ask for another player's key. Scripts that run without a key (open scripts) get Valid = false and empty fields.

FieldTypeValue
Validbooleantrue when an active key is locked to this device.
CodestringThe full key. Use Masked to show it on screen.
MaskedstringThe key with the middle hidden, like ABC...123.
PrefixstringThe key prefix, if you use one.
NotestringThe note you wrote on the key in the dashboard, for example "vip" or "giveaway".
TypestringHow the key was made, for example redeem or a key flow.
Lifetimebooleantrue when the key never expires.
ExpiresAtnumberUnix time the key ends. 0 for lifetime keys.
TimeLeftnumberSeconds until the key ends, counted live. 0 for lifetime keys, so check Lifetime first.
CreatedAt / FirstUsedAtnumberUnix times.
HwidLockedbooleantrue when the key is bound to a device.
Uses / MaxUsesnumberHow often the key was used and how often it may be.

LuaProtect.Discord

FieldTypeValue
Linkedbooleantrue when the player linked their Discord account (/link in your server or the in-game code).
IdstringThe Discord user id, or "" when not linked.
UsernamestringThe Discord username, or "" when not linked. It is looked up in the background, so the very first read can be empty: call LuaProtect:Refresh() a moment later.
DisplayNamestringThe Discord display name (global name), falling back to the username.
InvitestringYour server invite from the script settings, or "".

LuaProtect.Script

FieldTypeValue
IdstringThe script id.
NamestringThe script name.
VersionnumberThe release version this run came from, or 0 when you do not use releases.
ExecutionsnumberTotal executions of the script. Cached for about a minute.
UniqueUsersnumberDistinct players in the recent window.
Last24hnumberExecutions in the last 24 hours.

LuaProtect.Session

FieldTypeValue
IdstringThe session id, the same one the dashboard shows for this player.
StartedAtnumberUnix time this connection started.
Transportstring"ws" for a WebSocket, "https" for the long-poll fallback.

LuaProtect.Theme

The look the script owner picked in the Style tab. Use it to draw your own windows in the same colours as the key prompt, announcements and review card. Fields the owner left on the default are nil, except the status colours, radius and angle, which always carry the value in use.

FieldTypeValue
BackgroundColor3Card background.
Background2Color3Second background colour when a gradient is set, otherwise nil.
TextColor3Main text colour.
AccentColor3The accent, only when the owner set one (nil keeps your own colour).
Accent2Color3Second accent colour for a gradient, otherwise nil.
Success / Warning / DangerColor3Status colours.
AnglenumberGradient angle in degrees.
RadiusnumberCorner roundness the owner chose (0 to 24).
IconstringName of the brand icon, or nil.
local Theme = LuaProtect.Theme

local card = Instance.new("Frame")
card.BackgroundColor3 = Theme.Background
card.Size = UDim2.fromOffset(320, 160)
Instance.new("UICorner", card).CornerRadius = UDim.new(0, Theme.Radius)

if Theme.Background2 then
    local g = Instance.new("UIGradient", card)
    g.Color = ColorSequence.new(Theme.Background, Theme.Background2)
    g.Rotation = Theme.Angle
    card.BackgroundColor3 = Color3.new(1, 1, 1)
end

local accent = Theme.Accent or Color3.fromRGB(59, 130, 246)
A full example: The LuaProtect showcase script on ScriptBlox draws its whole window from LuaProtect.Theme plus the User, Key, Discord, Script, Storage and Feedback namespaces. It is a good starting point to copy from.

Example

local LP = LuaProtect

print(("Welcome %s! Run #%d of %s"):format(LP.User.Username, LP.User.Executions, LP.Script.Name))

if LP.Key.Valid then
    if LP.Key.Lifetime then
        print("Your key is lifetime. Note: " .. LP.Key.Note)
    else
        print(("Your key ends in %d hours"):format(math.floor(LP.Key.TimeLeft / 3600)))
    end
end

if not LP.Discord.Linked and LP.Discord.Invite ~= "" then
    print("Link your Discord for buyer roles: " .. LP.Discord.Invite)
end

Everything at once, and refreshing

-- One table with user, key, discord, script and session
local info = LuaProtect:Info()
print(info.key.Note, info.script.Executions)

-- Ask the server again (for example after the player redeemed a key).
-- Normal reads reuse the data for 30 seconds.
LuaProtect:Refresh()
local fresh = LuaProtect:Info(true)

How it behaves

The first read of a field asks the server once (it yields for a moment, usually well under a second); every later read is instant. The data is reused for 30 seconds, and a player can make at most about 2 fresh requests per second.

Fields never come back as nil. If the server cannot be reached, you get "", 0 or false, so you can join them into a string without a nil check. Check LuaProtect.Key.Valid before you rely on the key fields.

Do not enforce rules with these values: The script runs on the player's computer, and a player can change what a script sees. Use these values to greet players, show a countdown or unlock cosmetics. For anything that gives a reward or protects your data, check on your own server with the REST API.
What is never sent: Other players' data, IP addresses, the raw HWID, and anything from your account. Each player only gets their own session, on their own encrypted connection.