Protect your script
SA_INIT_SCRIPT
Run code before the whitelist — typically your own key UI — without it being obfuscated.
On this page
What it does
The function you pass to SA_INIT_SCRIPT is cut out of your source and runs before the obfuscated part, unobfuscated. Use it to show a key input UI, or anything that must happen before the whitelist checks the key.
Rules
- Only one
SA_INIT_SCRIPTper script. - The argument must be an inline function —
SA_INIT_SCRIPT(handler)fails obfuscation. - No upvalues: the function runs in its own context, so keep every helper inside it.
- The code is readable by anyone — never put secrets there.
- If your UI is asynchronous, block at the end until a key is set. Otherwise the whitelist starts early and kicks with "No key found".
Example: key UI
lua
SA_INIT_SCRIPT(function()
local lib = loadstring(game:HttpGet("https://api.santiauth.com/api/loader/v4/library.lua"))()
-- lib.service and lib.script_id are filled in for you inside SA_INIT_SCRIPT
local gui = --[[ your ScreenGui with a TextBox and Submit / Get key buttons ]]
gui.GetKey.Activated:Connect(function()
setclipboard(lib.get_key_url()) -- https://santiauth.com/a/my-hub
end)
gui.Submit.Activated:Connect(function()
local status = lib.check_key(gui.KeyBox.Text) -- never kicks
gui.Status.Text = status.message
-- on KEY_VALID the library sets getgenv().script_key for you
end)
repeat task.wait() until getgenv().script_key -- wait for a valid key
gui:Destroy()
end)
-- Protected code below only runs after the built-in whitelist passes.
print("Welcome,", SA_LinkedDiscordID)Inside SA_INIT_SCRIPT the library already knows your service slug and this script's ID — SantiAuth sets them when it builds the script. Set lib.service / lib.script_id yourself only to override them, or when you load the library from your own loader.