Data
Id
Generate identifiers of every shape, from GUIDs and sortable ids to human-friendly ticket codes and coupons.
PackageShared
Getting it
local Id = Engine:GetPackage("Id")Overview
Id is a single place for every kind of identifier a game needs. Each function returns a string.
local Id = Engine:GetPackage("Id")
print(Id.Guid()) --> 3f0b6c1e-9a2d-4c1e-8f2a-5b7d9e0a1c3b
print(Id.Order()) --> 172774560012300000042 (sorts by creation time)
print(Id.Ticket()) --> K7QD-M3XP
print(Id.Reference("TRD")) --> TRD-8HW2RNNote
Random parts come from Roblox's Random, which is fast but not cryptographically secure. For secrets such as session tokens use CryptographyService.
Lengths and formats marked "config" below come from the package configuration and can be changed per game.
Unique ids
| Function | Example | Notes |
|---|---|---|
Id.Guid() | 3f0b6c1e-9a2d-... | A lowercase GUID from HttpService. |
Id.Cuid() | clw3x0k1a8f2k9q3m | c + timestamp + counter + random (config), all base36. |
Id.Cuid2() | k1lw3x0k1b... | Starts with a letter; fixed total length (config). |
Random strings
| Function | Alphabet |
|---|---|
Id.Random(len?) | Base62 (0-9, A-Z, a-z). |
Id.Slug() | Base62, short (config). |
Id.Base58(len?) | Base58, without look-alike characters 0, O, I, l. |
Id.Base62(len?) | Base62. |
Id.Base85(len?) | Base85 with punctuation. |
Id.Binary(bits?) | 0 and 1. |
Id.Octal(len?) | 0-7. |
Id.Emoji(len?) | Random emoji. |
Id.Custom(alphabet, len) | Characters from your own alphabet. |
Sortable ids
| Function | Format |
|---|---|
Id.Lexical(len?) | 13-digit millisecond timestamp + random base36 suffix. String order equals creation order. |
Id.Order() | 13-digit timestamp + 8-digit counter. Strictly increasing within a server. |
Id.Filename() | Timestamp + - + random suffix. |
Id.Request() | Timestamp + random suffix. |
Server and thread ids
| Function | Description |
|---|---|
Id.Machine() | game.JobId on live servers, or STUDIO- + random in Studio. Same for the whole server. |
Id.Process() | Random id fixed for this Luau VM. |
Id.Thread() | Random id per coroutine, stable for that coroutine. |
Id.Worker(workerId) | w<id>-<timestamp>-<random>. |
Id.Shard(shardId) | s<id>-<timestamp>-<random>. |
Id.Trace() | 32 hex characters. |
Id.Span(traceId) | traceId + - + 16 hex characters. |
Human-friendly codes
These use an alphabet without characters that are easy to confuse (0/O, 1/I/L), so players can read them out or type them.
| Function | Example |
|---|---|
Id.Ticket() | K7QD-M3XP (groups and length from config) |
Id.License(len?) | 9XKQ-2MPD-H7RT-W4NB |
Id.Coupon(len?) | QW7ZK2MD |
Id.Reference(prefix?) | REF-8HW2RN |
Id.Temp() | tmp-a8Kd02Lx9Q |
Fake data
Handy for tests and placeholder UI.
| Function | Example |
|---|---|
Id.Color() | #3FA2C8 |
Id.IPv4() | 172.16.4.20 |
Id.IPv6() | 2001:0db8:85a3:... |
Configuration
Defaults from
DefaultConfiguration/Packages/Id28 settings| Setting | Default | What it does |
|---|---|---|
| CuidRandomLength | 8 | Random base36 characters appended to a Cuid. |
| Cuid2Length | 24 | Total length of a Cuid2. |
| SlugLength | 7 | Length of a Slug. |
| DefaultRandomLength | 16 | Length Id.Random() uses when no len is passed. |
| DefaultBinaryBits | 8 | Bits Id.Binary() uses when no count is passed. |
| DefaultOctalLength | 8 | Length Id.Octal() uses when no len is passed. |
| DefaultBase58Length | 12 | Length Id.Base58() uses when no len is passed. |
| DefaultBase62Length | 12 | Length Id.Base62() uses when no len is passed. |
| DefaultBase85Length | 12 | Length Id.Base85() uses when no len is passed. |
| DefaultEmojiLength | 4 | Emoji Id.Emoji() uses when no len is passed. |
| DefaultLexicalSuffixLength | 10 | Random suffix length after the timestamp in a lexical id when no len is passed. |
| MachineStudioIdLength | 12 | Random length of the machine id used in Studio, where game.JobId is empty. |
| ProcessIdLength | 16 | Length of the per-process id. |
| ThreadIdLength | 12 | Length of a per-thread id. |
| WorkerSuffixLength | 6 | Random suffix length appended to a worker id. |
| ShardSuffixLength | 6 | Random suffix length appended to a shard id. |
| RequestSuffixLength | 12 | Random suffix length appended to a request id. |
| TraceHexLength | 32 | Hex characters in a trace id. |
| SpanHexLength | 16 | Hex characters in a span id. |
| TicketGroups | 2 | Dash-separated groups in a ticket code. |
| TicketGroupLength | 4 | Characters per ticket group. |
| DefaultLicenseLength | 16 | Total characters in a license key when no len is passed. |
| LicenseGroupLength | 4 | Characters per dash-separated license group. |
| DefaultCouponLength | 8 | Length Id.Coupon() uses when no len is passed. |
| DefaultReferencePrefix | "REF" | Prefix Id.Reference() uses when none is passed. |
| ReferenceCodeLength | 6 | Characters after the prefix in a reference code. |
| FilenameSuffixLength | 8 | Random suffix length appended to a filename. |
| TempSuffixLength | 10 | Random length after "tmp-" in a temp id. |