Skip to main content

Running code before the auth

info

LuaAuth allows you to run code before the auth starts using its init macro

warning
  • This macro can only be used once in your script
  • The code inside this macro is extracted out, meaning you cant reference anything outside this function from within it
  • The function passed MUST be a constant, meaning you cant do something like la_token_ui(myFunc)
danger

This code is not locked behind auth, anyone can copy and run this code whenever they want!

Any code in this function is not garanteed to be run!
There is nothing stopping a user from overwriting the code in this function, even when obfuscated

How to use it

syntax: la_init(func: constant function, data: table)

func is a constant function

Data table

warning
  • You cannot add any other fields to this table
  • All fields must be the correct type
  • You can leave fields blank
FieldTypeDefaultDescription
obfuscateBooleanFalseObfuscate the code using Luraph, will cost you an extra obfuscation but stops users from being able to view your source
if you disable this option we will still minify your code
asyncBooleanFalseRun the code async to the main script, meaning it wont block the main scripts execution
danger

If you chose to not obfuscate the code, then DO NOT leave anything important in this function
Minified code is still very readable

Example

la_init(function()
if game.PlaceId ~= 123456789 then
game:GetService('Players').LocalPlayer:Kick('This script must be ran in example')
end

local keyProvided = false
-- ui stuff here, sets keyProvided = true when done

while not keyProvided do -- since async is false this will stop main script from loading, if async was true this wouldnt stop the main script at all
task.wait()
end
end, {
obfuscate = false,
async = false
})