Globals and modules
Everything a script can use without require. Members are camelCase; modules are called with a dot (net.send), objects with a colon (part:tween).
Containers
| Global | What it is |
|---|---|
game | The game: isServer, isClient, frame, closing, and the containers below |
world | The World: every part players see. world:raycast(origin, direction), world.streamingRadius, world.replication |
shared | ReplicationService: models and Modules both sides have |
game.ServerService, game.ClientService, game.StorageService | The other containers |
lighting | The time of day and the light - see Sounds, lights and effects |
teams | The game's teams |
script | This script; script.parent is what it is in |
game
| Member | |
|---|---|
game.isServer, game.isClient | Which side this script is on |
game.frame | Event every frame (server: every step), with the seconds since the last |
game.closing | Event (server): the server is shutting down - save what you need. Waits up to 20 s |
world
| Member | |
|---|---|
world:raycast(origin, direction) | nil, or {part, position, normal, distance} |
world.streamingRadius | Server: 0 sends every player the whole world; a number streams it in by distance |
world.replication | Server: how often movement reaches players by distance - {near = 150, mid = 400, midEvery = 3, farEvery = 12}; set any of them |
players
| Member | |
|---|---|
players.joined | Event: a player joined |
players.left | Event: a player is leaving (they can still be read) |
players.all() | Everyone in the game |
players.fromPart(part) | The player whose character the part belongs to, or nil |
players.me | ClientScripts: this device's player |
net - messages between server and players
| Function | Side | |
|---|---|---|
net.send(player, name, ...) | Script | To one player |
net.sendAll(name, ...) | Script | To every player |
net.send(name, ...) | ClientScript | To the server |
net.on(name, fn) | Both | Receive. On the server fn(player, ...) |
net.call(name, ...) | ClientScript | Ask the server and wait for its answer |
net.handle(name, fn) | Script | Answer net.calls: fn(player, ...) returns the answer |
See Server and client.
input (ClientScripts)
| Member | |
|---|---|
input.onKey(key, fn) | fn when the key is pressed (not while typing). Returns the connection |
input.isDown(key) | Whether the key is held now |
input.began, input.ended | Events (inputObject, typing): inputObject.key, inputObject.type |
input.mouseFree | True: the pointer is shown and free in first person / camera lock |
camera (ClientScripts)
mode, transform, position, fov, target, minZoom, maxZoom, offset, firstPerson, firstPersonArms, viewportSize, ray(distance?), toScreen(position), tween(goals, time). See Input and camera.
data (Scripts)
data.store(name) returns a store with get(key), set(key, value), update(key, fn), increment(key, delta?), remove(key). Each waits and errors on failure - use pcall. See Saving data.
chat (Scripts)
chat.send(message) - a system line in every player's chat.
physics
| Function | |
|---|---|
physics.collide(a, b, yes?) | Whether parts in group a collide with group b (yes left out is true) |
physics.collides(a, b) | Whether they do |
tags
| Function | |
|---|---|
tags.get(tag) | Everything in the game with the tag |
tags.each(tag, fn) | fn for each now and each later |
tags.added(tag), tags.removed(tag) | Events |
tags.all() | Every tag in use |
See Tags and attributes.
building (settings: server Scripts)
enabled, limit, reach, blockSize, loose, keepOnLeave, removeAny; events placed(player, block), removed(player?, block); count(player), blocks(player?), remove(block, shatter?). See Building, destruction, achievements.
destruction (Scripts)
shatter(part, options?), explode(position or part, options?), detach(part), repair(part), clear(), debrisCount(), configure(settings?).
achievements (Scripts)
achievements.award(player, key, name?, description?) - returns true when it gave it now.
json
json.encode(value, pretty?), json.decode(text).
Making things and values
| Global | |
|---|---|
new(className, parent?) | A new object - see Classes |
vec3(x, y, z) | A 3D vector: vec3.zero, vec3.one, vec3.up |
vec2(x, y) | A 2D vector: vec2.zero, vec2.one |
rgb(r, g, b) | A colour, 0-255; or rgb("#ffaa00") |
hsv(h, s, v) | A colour from hue, saturation, value, 0-1 |
transform(...) | A position and a turn: transform(x, y, z), transform(position), transform.lookAt(from, to), transform.angles(rx, ry, rz), transform.identity |
dim(xScale, xOffset, yScale, yOffset) | A UI size or position: dim.scale(x, y), dim.px(x, y) |
See Value types.
Time and threads
| Global | |
|---|---|
task.wait(seconds?) | Waits (a frame when left out); returns the time waited |
task.spawn(fn, ...) | Runs fn now, alongside |
task.delay(seconds, fn, ...) | Runs fn after a while |
task.defer(fn, ...) | Runs fn at the end of this step |
time() | Seconds since the game started |
Luau
print, warn, require, typeof, pcall, error, assert, tostring, tonumber, ipairs, pairs, select, type, setmetatable... and the libraries math, string, table, os, utf8, bit32, buffer, coroutine. See luau.org.
Roblox's names
workspace, Instance.new, Vector3, CFrame, Color3, UDim2, TweenInfo, Enum, wait, tick, game:GetService(...) and the rest still run. See Coming from Roblox.