Roblox UtilitiesDevlHub Roblox Documentation

Global

Roblox globals

Built-in functions and constants unique to Roblox.

Roblox provides several unique built-in functions and variables in its embedding of Luau. These are only found on Roblox and are not packaged by default with Luau or Lua.

Properties 6#

EnumEnumsContains all Enum objects.
gameDataModelRefers to the DataModel singleton, the root instance of a place's hierarchy.
pluginPluginRefers to a Plugin singleton when the code is run in the context of a Studio plugin.
sharedArrayA table shared between all code running at the same execution context level.
scriptLuaSourceContainerA reference to the LuaSourceContainer object (Script, LocalScript, or ModuleScript) that is executing this code.
workspaceWorkspaceA reference to the Workspace service, which contains all of the physical components of a place.

Enum: Enums#

A reference to the Enums data type, which stores all of the available enums that can be used on Roblox.

game: DataModel#

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 run from this Script. This reference exists only in the context where a script is executed as a plugin and is not passed to ModuleScripts within the plugin. To use this reference in a ModuleScript, you must explicitly pass it.

shared: Array#

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

script: LuaSourceContainer#

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. 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.

Functions 16#

delaySchedules a function to be called on the next Heartbeat after the given duration (in seconds) has passed, with throttling.Deprecated
DebuggerManagerRefers to the legacy DebuggerManager class which acts as an interface for the Luau debugger feature.Deprecated
elapsedTimeReturns the amount of time in seconds that the current instance of Roblox has been running for.
PluginManagerRefers to the PluginManager, a deprecated singleton that was previously required to create plugins.
printidentityPrints "Current identity is X", where X corresponds to the current thread's security context level.
settingsReturns the GlobalSettings object, which can be used to access settings objects that configure Roblox Studio's behavior.
spawnCalls a function immediately through the engine scheduler, with throttling.Deprecated
statsReturns the Stats service.
tickReturns the amount of time in seconds since the Unix epoch according to this device's time.
timeReturns the amount of time in seconds that has elapsed since the current game instance started running.
typeofReturns the type of the given object as a string, also supporting Roblox-specific types (e.g. Vector3).
UserSettingsReturns the UserSettings object, which is used to read information from the current user's game menu settings.
versionReturns the current version of Roblox as a string, which includes the generation, version, patch and commit.
waitYields the current thread until the specified amount of time in seconds have elapsed, with throttling.Deprecated
warnBehaves similarly to print, except with more distinct formatting (yellow); intended for messages which describe potential problems.
ypcallLegacy function to work around an old task scheduling limitation of LuaGlobals.pcall().

delay(delayTime: number, callback: function): ()#

DeprecatedDeprecated

Deprecated. This method has been superseded by task.delay() and should not be used for future work.

Schedules a function to be executed after delayTime seconds have passed, without yielding the current thread. This function allows multiple Luau 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.

NameTypeDefaultDescription
delayTimenumberThe amount of time that this function will be queued before being executed.
callbackfunctionThe function that will be executed once delayTime seconds have passed.
Returns
  • ()

DebuggerManager(): DebuggerManager#

DeprecatedDeprecated

Deprecated. The DebuggerManager is obsolete and serves little to no use case for developers.

Returns the legacy DebuggerManager class which acts as an interface for Roblox's Luau debugger feature.

This function is not recognized by Luau's analysis tool and will raise an undefined global warning.

Returns
  • DebuggerManager — The DebuggerManager singleton instance.

elapsedTime(): number#

Deprecated

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.

Returns
  • number — The elapsed time, in seconds, since the current Roblox instance started running.

PluginManager(): PluginManager#

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

Returns

printidentity(prefix: string = Current identity is): ()#

Deprecated

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

NameTypeDefaultDescription
prefixstringCurrent identity isA custom string to print before the identity number; if omitted, defaults to "Current identity is".
Returns
  • ()

settings(): GlobalSettings#

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

Returns
  • GlobalSettings — The GlobalSettings singleton used to access Roblox Studio's settings objects.

spawn(callback: function): ()#

DeprecatedDeprecated

Deprecated. This method has been superseded by task.spawn() and should not be used for future work.

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.

The callback function is invoked with two arguments:

  1. The first being the amount of time which elapsed from when spawn was called to when the function was invoked.
  2. The second being equivalent to elapsedTime() or roughly how long the engine has been running.
NameTypeDefaultDescription
callbackfunctionThe function that will be executed.
Returns
  • ()

stats(): Stats#

Deprecated

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

Returns
  • Stats — The Stats service instance.

tick(): number#

Returns how much time has elapsed, in seconds, since the Unix epoch, on the current local session's computer. The Unix epoch is represented by 00:00:00 on 1 January 1970.

tick() isn't officially deprecated, but has a variety of issues. It can be off by up to one second and returns inconsistent results across time zones and operating systems. Use os.time(), os.clock(), or RobloxGlobals.time() instead. Also consider DateTime.UnixTimestamp and DateTime.UnixTimestampMillis.

Returns
  • number — The elapsed time, in seconds, since the Unix epoch (January 1, 1970) according to the local device clock.

time(): number#

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

If Workspace.AuthorityMode is AuthorityMode.Server, this value is synchronized between client and server.

Returns
  • number — The elapsed time, in seconds, since the current game instance started running.

typeof(object: Variant): string#

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

NameTypeDefaultDescription
objectVariantThe Luau type that will have its type checked.
Returns
  • string — A string representation of the object's type, including Roblox-specific types such as "Vector3" or "CFrame".

UserSettings(): UserSettings#

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

Returns

version(): string#

Deprecated

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.
Returns
  • string — A period-separated version string in the format "generation.version.patch.commit".

wait(seconds: number = 0.03): number, number#

DeprecatedDeprecated

Deprecated. This method has been superseded by task.wait() and should not be used for future work.

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).
NameTypeDefaultDescription
secondsnumber0.03Specifies how long the thread should yield for.
Returns
  • number — The actual time yielded, in seconds.
  • number — The total time elapsed since the engine started, in seconds.

warn(params: Tuple): ()#

Behaves identically to Luau'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.

NameTypeDefaultDescription
paramsTupleThis function accepts any number of arguments, and will attempt to convert them into strings which will then be joined together with spaces between them.
Returns
  • ()

ypcall(f: function, args: Tuple): bool, Variant#

Deprecated

Legacy function to work around an old task scheduling limitation of LuaGlobals.pcall(); should not be used for new work (use LuaGlobals.pcall() instead).

NameTypeDefaultDescription
ffunctionThe function to be called in protected mode.
argsTupleAdditional arguments to pass to the function.
Returns
  • bool — Whether the function executed successfully without raising an error.
  • Variant — The return values of the function on success, or the error message on failure.