Globals and services

Everything a script can use without declaring it: global names, services, library helpers, and the Studz utility tables.

Globals

GlobalDescription
gameThe DataModel. game.Workspace, game.Players, game:Service(name), and the storage containers.
workspaceThe root 3D scene container.
scriptThe running Script, LocalScript or ModuleScript object.
script.ParentThe script's parent: a Part, Model, Folder or the workspace.
Lighting, Players, RunService, Debris, TweenService, GuiService, StarterGuiThe services, also available as globals.
InstanceInstance.new and Instance.Create. See Instances and parts.
Vector3, Vector2, CFrame, Color3, UDim, UDim2, Ray, RaycastParams, TweenInfo, EnumConstructors 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, SoundStudz utility tables. See Studz utility tables.

Library additions

Lua 5.4's standard library plus these helpers.

FunctionDescription
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.difftimeThe only os functions available.

Services

Get a service with game:Service(name). The name is checked: a typo is an error with a suggestion.

ServicePurpose
WorkspaceThe 3D scene.
PlayersPlayers. See Players and characters.
RunServiceFrame events and environment checks.
DebrisDelayed cleanup.
TweenServiceAnimations.
LightingTime of day and ambient light.
GuiService, StarterGuiScript-made GUI.
DataStoreServiceSaved numbers.
UserInputServiceInput (client).
HttpServiceJSON and ids.
CollectionServiceTags.
ReplicatedStorage, ServerStorage, ReplicatedFirst, ServerScriptService, StarterPlayerContainers. Objects placed anywhere are also found through them.
Chat, TextChatService, ChatServiceChat (broadcast only).

RunService

MemberDescription
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

MethodDescription
: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)

FunctionDescription
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

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

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