Globals and services
Everything a script can use without declaring it: global names, services, library helpers, and the Studz utility tables.
Globals
| Global | Description |
|---|---|
game | The DataModel. game.Workspace, game.Players, game:Service(name), and the storage containers. |
workspace | The root 3D scene container. |
script | The running Script, LocalScript or ModuleScript object. |
script.Parent | The script's parent: a Part, Model, Folder or the workspace. |
Lighting, Players, RunService, Debris, TweenService, GuiService, StarterGui | The services, also available as globals. |
Instance | Instance.new and Instance.Create. See Instances and parts. |
Vector3, Vector2, CFrame, Color3, UDim, UDim2, Ray, RaycastParams, TweenInfo, Enum | Constructors and enums. |
typeof(v) | Engine-aware type name: "Vector3", "CFrame", "Instance" and so on. |
print(...) | Writes to the Output window. |
warn(...) | Writes a warning (yellow) to the Output window. |
error(...) | Lua's own error. |
tick() | Unix time in seconds, with millisecond precision. |
require(module) | Runs a ModuleScript once and returns its value. Cyclic requires are an error. |
chat, server, ui, Sound | Studz utility tables. See Studz utility tables. |
Library additions
Lua 5.4's standard library plus these helpers.
| Function | Description |
|---|---|
math.clamp(n, lo, hi) | Limits n to the range. |
math.sign(n) | -1, 0 or 1. |
math.round(n) | Rounds to the nearest whole number. |
math.map(n, a, b, c, d) | Re-maps n from the range a..b to c..d. |
math.lerp(a, b, t) | Linear interpolation. |
math.noise(x, [y], [z]) | Perlin noise from -1 to 1. |
table.find(t, value) | Index of a value, or nil. |
table.clone(t) | A shallow copy. |
table.clear(t) | Removes every entry. |
os.time, os.clock, os.date, os.difftime | The only os functions available. |
Services
Get a service with game:Service(name). The name is checked: a typo is an error with a suggestion.
| Service | Purpose |
|---|---|
Workspace | The 3D scene. |
Players | Players. See Players and characters. |
RunService | Frame events and environment checks. |
Debris | Delayed cleanup. |
TweenService | Animations. |
Lighting | Time of day and ambient light. |
GuiService, StarterGui | Script-made GUI. |
DataStoreService | Saved numbers. |
UserInputService | Input (client). |
HttpService | JSON and ids. |
CollectionService | Tags. |
ReplicatedStorage, ServerStorage, ReplicatedFirst, ServerScriptService, StarterPlayer | Containers. Objects placed anywhere are also found through them. |
Chat, TextChatService, ChatService | Chat (broadcast only). |
RunService
| Member | Description |
|---|---|
Frame:On(function(dt) end) | Every simulation step. (Heartbeat is the deprecated Roblox name.) |
Draw:On(function(dt) end) | Every rendered frame, on a client. (RenderStepped is deprecated.) |
IsServer(), IsClient() | Which side the script runs on. |
IsStudio(), IsRunning() | Whether it runs in Polycarbonate, and whether the game is running. |
Debris
Debris:AddItem(instance, seconds) is deprecated: use instance:DestroyAfter(seconds), which destroys the instance later without blocking the script.
HttpService
| Method | Description |
|---|---|
:JSONEncode(v) | Turns a table into a JSON string. |
:JSONDecode(s) | Turns a JSON string into a table. |
:GenerateGUID() | A new unique id. |
:UrlEncode(s) | Percent-encodes a string. |
Web requests (GetAsync, PostAsync, RequestAsync) are not available and raise an error.
CollectionService
:AddTag(inst, tag), :RemoveTag(inst, tag), :HasTag(inst, tag), :GetTags(inst) and :GetTagged(tag). See Instances and parts for the matching inst: methods and attributes.
Services Studz does not have
Roblox services such as MarketplaceService, TeleportService, ContextActionService and Teams return an inert object and warn once, so a ported script that only declares them still runs.
Studz utility tables
These are lowercase-named tables of helper functions. They exist so common jobs take one line.
chat: system chat messages (server)
| Function | Description |
|---|---|
chat.broadcast(text) | A system message to everyone. |
chat.announce(text) | An announcement to everyone. |
chat.whisper(player, text) | A private message to one player. |
server: player management
| Function | Description |
|---|---|
server.kick(player, [reason]) | Same as player:Kick. Works by name or player. |
server.teleport(player, pos) | Same as player:Teleport. |
server.broadcast(text) | Same as chat.broadcast. |
ui: quick GUI
Build GUI from a table or positional arguments.
| Function | Description |
|---|---|
ui.frame(...) | Makes a frame. |
ui.text(...) | Makes a text label. |
ui.button(...) | Makes a button. |
ui.notify(title, text, seconds) | Shows a short notification: ui.notify("Saved", "Game saved", 3). |
ui.clear() | Removes script-made GUI. |
Sound: audio
Sound.play, Sound.stop and Sound.stopAll. See World, tweens and effects.
