Script environment

All custom global variables available in the script environment.

Global variables

All built-in functions and variables in vanilla Luau are also available to use in razvanSB with the exception of the debug library.

const Instance script

A constant reference to the script.

const string _VERSION

A constant reference to the version of the interpreter and compiler.

print(_VERSION) -- output: Luau

const Player owner

A constant reference to the player who owns the script.

-- the owner of this script is Players.RazvanJTL
print(owner.Name) -- output: RazvanJTL
print(owner.Character) -- output: player's character

Global functions

const function require(module: number | ModuleScript, silenced: boolean?): any

The constant require function that functions just like in vanilla Luau. However, it has been modified to serve restrictions on its usage and to be able to prevent the call stack from being printed to the developer console.

-- attempting to require a MainModule (asset ID) without
-- meeting the 112x4 privilege level requirement will result in a error
require(1, true)(owner and owner.Name) -- error: attempted to use restricted global (require)

-- require can also load ModuleScripts that have been instantiated through
-- the means of using NewModuleScript
local get_contents = require(NewModuleScript([[
return function()
    return "hi"
end)
]])) -- returns: () -> string

print(get_contents()) -- output: hi

const function NewScript(source: string, parent: Instance?): Script

Constant function that instantiates a server script which has the purpose of running the specified code. The parent argument defaults to ServerScriptService if no parent has been specified.

Aliases: NS, ns, new_script

NewScript([[
print("hi,", owner.Name)
]]) -- output: hi, RazvanJTL

const function NewLocalScript(source: string, parent: Instance?): LocalScript

Constant function that instantiates a local script which has the purpose of running the specified code. The parent argument defaults to the script's owner if no parent has been specified.

Aliases: NLS, nls, new_local_script

The owner global will not be re-evaluated to the first Player ancestor and wont necessarily be the LocalPlayer. It is still the player who created the local script.

local Players = game:GetService("Players")

NewLocalScript([[
print(owner.Name)
]], Players.SomeoneYouDontKnow) -- output on client-side: RazvanJTL

const function NewModuleScript(source: string): () -> any

Constant function that instantiates a module script.

Aliases: NMS, nms, new_module_script

Note that all module scripts instantiated through the means of using NewModuleScript will always have the same environment as the script that instantiated them.

local module = NewModuleScript([[
return {
    do_something = function() 
        -- does something
        return nil
    end
}
]]) -- returns: executable -> {do_something: () -> any}

print(module().do_something()) -- output: nil
print(require(module).do_something()) -- output: nil

const @deprecated function LoadLibrary(library: "RbxGui" | "RbxStamper" | "RbxUtility"): any

Constant function that executes and returns the contents of the specified library.

Aliases: loadLibrary, load_library

const function print(...: any)

Prints all specified arguments to the console.

Note that all outputs on the server-side, including errors and warnings, will be instead redirected to be shown on the client-side developer console.

const function warn(...: any)

Acts the same as print , with the only difference being that the color of the output will be yellow.

const function error(exception: string, level: number)

Outputs an error to the console and halts the execution of the script if the error isnt caused in protected mode. If no level of information that will be outputted has been explicitly specified, it will default to 1.

Last updated