PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Roblox Globals

Roblox Globals

Roblox has several unique built-in functions and variables in its Lua implementation.
These are only found on Roblox, and are not packaged by default with Lua.

Functions

void delay ( number delayTime, function callback )

Schedules a function to be executed after delayTime seconds have passed, without yielding the current thread. This function allows multiple Lua threads to be executed in parallel from the same stack. The delay will have a minimum duration of 29 milliseconds, but this minimum may be higher depending on the target framerate and various throttling conditions. If the delayTime parameter is not specified, the minimum duration will be used.

DebuggerManager DebuggerManager ( )

Returns the DebuggerManager class, which acts as an interface for Roblox’s Lua debugger feature.

number elapsedTime ( )

Returns how much time has elapsed since the current instance of Roblox was started.
In Roblox Studio, this begins counting up from the moment Roblox Studio starts running, not just when opening a place.

RbxLibrary LoadLibrary ( string libraryName )

Returns a built-in Roblox library, based on the libraryName specified.
There are currently 3 available libraries:

  • RbxGui
  • RbxUtility
  • RbxStamper
PluginManager PluginManager ( )

Returns the PluginManager which is a deprecated singleton that was previously required to create plugins. It still has applicable uses, such as if you need to create a Plugin object from Roblox Studio’s command bar.

void printidentity ( string prefix = "Current identity is" )

Prints Current identity is [ID] to the output, where [ID] corresponds to the current thread’s security context level.

Variant require ( ModuleScript module )

Runs the supplied ModuleScript if it has not been run already, and returns what the ModuleScript returned (in both cases).

If the ModuleScript the user wants to use has been uploaded to Roblox (with the instance’s name being ‘MainModule’), it can be loaded by using the require function on the asset ID of the ModuleScript, though only on the server.

GlobalSettings settings ( )

Returns the GlobalSettings object, which can be used to access the settings objects that are used in Roblox Studio’s settings menu.

void spawn ( function callback )

Runs the specified callback function in a separate thread, without yielding the current thread.
The function will be executed the next time Roblox’s Task Scheduler runs an update cycle. This delay will take at least 29 milliseconds but can arbitrarily take longer, depending on the target framerate and various throttling conditions.

Stats stats ( )

Returns the Stats service.
It is preferred that developers use ServiceProvider/GetService to retrieve it instead.

number tick ( )

Returns how much time has elapsed since the UNIX epoch, on the current local session’s computer.
The UNIX epoch is represented by the date January 1st, 1970.

number time ( )

Returns the amount of time that has elapsed since the current game instance started running.
If the current game instance is not running, this will be 0.

string typeof ( Variant object )

Returns the type of the object specified, as a string.
This function is more accurate than Lua’s native type function, as it does not denote Roblox-specific types as userdata.

UserSettings UserSettings ( )

Returns the UserSettings object, which is used to read information from the current user’s game menu settings.

string version ( )

Returns the current version of Roblox as a string. The integers in the version string are separated by periods, and each integers represent the following, in order:

Generation - The current generation of the application shell that is hosting the client.
Version - The current release version of Roblox.
Patch - The current patch number for this version of Roblox.
Commit - The ID of the last internal commit that was accepted into this version of the client.

number, number wait ( number seconds = 0.03 )

Yields the current thread until the specified amount of seconds have elapsed.
The delay will have a minimum duration of 29 milliseconds, but this minimum may be higher depending on the target framerate and various throttling conditions. If the seconds parameter is not specified, the minimum duration will be used.
This function returns:

  • Actual time yielded (in seconds)
  • Total time since the software was initialized (in seconds)
void warn ( Tuple params )

Behaves identically to Lua’s print function, except the output is styled as a warning, with yellow text and a timestamp.
This function accepts any number of arguments, and will attempt to convert them into strings which will then be joined together with spaces between them.

Variables

Enums Enum

A reference to the DataType/Enums datatype, which stores all of the available enums that can be used on Roblox.

DataModel game

A reference to the DataModel, which is the root Instance of Roblox’s parent/child hierarchy.

Plugin plugin

A reference to the Plugin object that represents the plugin being ran from this Script.
This reference only exists in the context where a script is executed as a plugin.

array shared

A table that is shared across all scripts that share the same execution context level.
This serves the exact same purpose as _G.

LuaSourceContainer script

A reference to the script object that is executing the code you are writing.
It can be either a Script, a LocalScript, or a ModuleScript (and sometimes a CoreScript)
This variable is not available when executing code from Roblox Studio’s command bar.

Workspace workspace

A reference to the Workspace service, which contains all of the physical components of a Roblox world.