Loomreference

Services

The Roblox services loom implements, the ones that are only containers, and the ones that throw when called.

@rbxts/services needs no setup. Each export is the same object game.GetService(...) returns.

import { HttpService, RunService, UserInputService } from "@rbxts/services";
HttpService === game.GetService("HttpService"); // true

What loom implements

ServiceWhat loom provides
CollectionServiceA real tag registry: AddTag, HasTag, GetTagged and the added/removed signals. Tags set in code only; there is no Studio tag editor.
ContextActionServiceBindAction, BindActionAtPriority, UnbindAction, UnbindAllActions, GetBoundActionInfo, GetAllBoundActionInfo. Bindings fire highest priority first, and the latest first among equal priorities. A handler returning Sink stops the chain; returning nothing is Pass. The touch-button members exist and do nothing, and BindAction creates no button.
ContentProviderPreloadAsync and RequestQueueSize.
DebrisAddItem(instance, lifetime) on a real timer. The instance is destroyed.
GuiServiceSelectedObject with selection signals, GetGuiInset, ReducedMotionEnabled.
HttpServiceGenerateGUID and the JSON pair. See below.
PlayersLocalPlayer with a pre-built PlayerGui, UserId, DisplayName and GetUserThumbnailAsync.
RunServiceRenderStepped, Heartbeat, PostSimulation, Stepped, BindToRenderStep, IsStudio, IsRunning, IsClient, IsServer.
StarterGuiA real container. SetCore, GetCore, SetCoreGuiEnabled and GetCoreGuiEnabled are no-ops.
TextServiceGetTextSize and GetTextBoundsAsync. See below.
TweenServiceCreate and real tween playback. See Animation.
UserInputServiceInput signals, GetMouseLocation, GetFocusedTextBox, capability flags, IsKeyDown, GetKeysPressed, IsMouseButtonPressed, GetLastInputType.
WorkspaceCurrentCamera with a live ViewportSize. Also reachable as game.Workspace, like every service.

These services are plain containers, so you can parent a tree into them: Lighting, ReplicatedFirst, ReplicatedStorage, ServerScriptService, ServerStorage, SoundService, StarterPack, StarterPlayer, Teams.

Unimplemented services

These are exported but not implemented, because each needs a Roblox server:

AnalyticsService, DataStoreService, LocalizationService, LogService, MarketplaceService, MessagingService, PolicyService, Stats, TeleportService, TextChatService.

Importing one is safe. It logs one console warning at startup, then throws, naming the member, on the line that calls it.

To provide one yourself, point a shim at @rbxts/services and re-export loom’s singletons alongside your own.

TextService

import { TextService } from "@rbxts/services";
const bounds = TextService.GetTextSize(
"Hello world",
18,
Enum.Font.SourceSans,
new Vector2(200, 1000),
);
MemberBehavior
GetTextSize(text, fontSize, font, frameSize)Measures with the same fonts the renderer paints with. Wraps greedily at word boundaries. A frameSize.X of 0 means no frame.
GetTextBoundsAsync(params)The same measurement, read from a GetTextBoundsParams instance. Does not yield.
Filtering methodsAbsent. Moderation is a server call.

The metrics come from the browser, so shaping and rounding can differ from the engine by a glyph. Which typeface answers depends on the fonts you install. See Fonts and text metrics.

HttpService

import { HttpService } from "@rbxts/services";
const id = HttpService.GenerateGUID(false);
MemberBehavior
GenerateGUID(wrapInCurlyBraces?)A lowercase RFC 9562 version 4 UUID in 8-4-4-4-12 form. wrapInCurlyBraces defaults to true, as in Roblox, so GenerateGUID(false) returns the bare 36 characters.
JSONEncode / JSONDecodeJSON.stringify / JSON.parse. Arrays and objects encode as they do in Studio. JSONEncode(undefined) returns "null". Malformed JSONDecode input throws.
GetAsync / PostAsync / RequestAsyncThrow by name. A preview never makes requests for you.
UrlEncodeAbsent. The engine encodes more than encodeURIComponent does.

GenerateGUID uses the Web Crypto API: crypto.randomUUID() in secure contexts, otherwise crypto.getRandomValues(). Without Web Crypto it throws instead of generating a weak ID:

[loom] HttpService.GenerateGUID requires the Web Crypto API

Datatype helpers worth knowing

const accent = Color3.fromHex("#6366F1");
Color3.fromRGB(99, 102, 241).ToHex(); // "6366f1"
Color3.fromHex(colour.ToHex()) === colour; // by value
DatatypeNotes
Color3.fromHexThree or six RGB hex digits, either case, with or without one leading #. Three digits double each one, so #fff is white. Alpha channels, 0x notation and stray whitespace throw a located loom error.
Color3:ToHex()Six lowercase digits, no #. Each channel is clamped and rounded to the nearest 255th.
Color3:ToHSV() / Color3.fromHSV(h, s, v)ToHSV() destructures as a tuple. fromHSV is its inverse.
Vector2Unit, Dot, Cross, Lerp, Min, Max, Abs, Floor, Ceil, Sign, Angle, FuzzyEq, and the xAxis / yAxis constants.
Vector3The equivalents of the Vector2 members.
UDim2Lerp, and the Width / Height components.
UDimNo methods, as in the engine.
FontFont.fromId.
NumberRangeMin / Max.
ContentContent.fromUri, Content.fromObject, Content.none.
ColorSequenceKeypoint / NumberSequenceKeypointConstructed with .new, as roblox-ts writes every construction.