Global namespace/Roblox namespace
Roblox has several unique built-in APIs found in it's Lua environment. These are only found on Roblox, and are not packaged by default with Lua.
|game||A reference to the DataModel, which is the root class of the parent-child hierarchy on Roblox.|
|Enum||A static variable that lets you access all of Roblox's official enums, which are used with various APIs on Roblox.|
|plugin||A variable that is only present when the code is being ran in a plugin. Represents the Plugin object associated with the plugin itself.|
|script||A variable that is only present when the code is being ran by a LuaSourceContainer. This can be either a Script, a LocalScript or a ModuleScript.|
|shared||A table, that is shared with scripts of the same context level. This functions identically to the _G table.|
|workspace||A reference to the Workspace, which is where all physically interactive objects are located.|
|Axes||Allows you to specify what axes should be visible on an ArcHandles object.|
|BrickColor||A list of roughly 200 pre-determined colors that you can apply to BaseParts.|
|CFrame||A means of representing both position, and orientation, as well as relative space between objects.|
|Color3||Allows you to construct any color, with either RGB values, or HSV values.|
|ColorSequence||Represents a sequence of Color3 values and times. Used with the ParticleEmitter class.|
|ColorSequenceKeypoint||Represents a keypoint in a ColorSequence.|
|DockWidgetPluginGuiInfo||Used to describe details for a newly created PluginGui.|
|Faces||Allows you to specify what faces can be dragged with a Handles object.|
|Instance||Allows you to construct most classes that are listed on the API Class reference.|
|NumberRange||Represents a numerical range of values, between the specified Min/Max values.|
|NumberSequence||Represents a sequence of changes to a numerical value over time.|
|NumberSequenceKeypoint||Specifies a time, value, and envelope point in a NumberSequence.|
|PathWaypoint||Represents a point to be reached and an action to take, when traversing a Path|
|PhysicalProperties||Represents the physical properties of a BasePart, which can be changed using the CustomPhysicalProperties property.|
|Random||A pseudorandom number generator object with a discrete state.|
|Ray||Represents a line starting at a 3D point, that travels infinitely in one direction. Used for raycasting.|
|Rect||Represents a rectangular crop when using the SliceCenter GUI feature.|
|Region3||Represents a world-space bounding box, defined by two coordinates. Primarily used with Terrain.|
|Region3int16||Similar to Region3, but uses Vector3int16 coordinates instead of Vector3 coordinates.|
|TweenInfo||Represents information about an in-between interpolation.|
|UDim||Represents a universal dimension, which can dynamically be changed based on the width/height of the screen. Generally overshadowed by UDim2.|
|UDim2||Represents two universal dimensions; one for the X-axis of the user's screen, and one for the Y-axis. Used with GUI elements.|
|Vector2||Represents a two-dimensional coordinate system, on the X/Y axis.|
|Vector3||Represents a three-dimensional coordinate system, on the X/Y/Z axis.|
|Vector3int16||Similar to Vector3, but the coordinates are integers constrained between -32,768 and 32,768, and there are no APIs for magnitude/unit measurement, dot/cross products, or lerping.|
A few quick things to note:
- Functions with a
strikethrough their name are deprecated, and thus are no longer supported by Roblox. You can use these functions, but it's not recommended.
- Functions that have italicized text cannot be used in normal Scripts and LocalScripts
Schedules a function to be called after delayTime seconds have elapsed.
Returns how many seconds have elapsed since the program was started.
Returns a built-in Roblox library, based on the libraryName specified.
The following example iterates over the functions present in the RbxGui library, and prints the documentation of each function.
- This function is obsolete in plugins, as the plugin variable is now always declared in scripts that are running plugins.
Prints the identity level of the current thread to the output.
From a Script:
From the command bar:
From a plugin:
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.
Runs the supplied ModuleScript if it has not been run already, and returns what the ModuleScript returned (in both cases).
--ModuleScript in the workspace print("ModuleScript loaded for the first time") return "Hello, world!"
Returns the user's GlobalSettings.
- Changes that are made to any of the settings will not be saved unless the user opens and closes the settings menu in Roblox Studio.
Schedules a function to be called in a separate thread in the next task scheduler step.
Returns the Stats service.
Returns the number of seconds that have elapsed since the UNIX epoch (January 1st, 1970), on your computer.
- Unlike standard UNIX time, the value returned from this function also measures milliseconds.
Returns the number of seconds that have elapsed since the game started running.
- The game must be running, or else the value will be 0.
Returns a string representing what kind of object was inputted.
Returns the client's UserSettings.
- This function should only be used in a LocalScript.
Returns the string value representation of Roblox's version.
Yields the current thread until the specified amount of seconds have elapsed.
If the seconds parameter is not specified, then it yields for a very short period of time (usually close to 1/30th of a second).
The function returns 2 values:
- The actual time that was elapsed
- The time that has elapsed since the program was started.
Functions identically to print, except the output is styled as a warning, with yellow text and a timestamp.