Roblox UtilitiesDevlHub Roblox Documentation

Data type

User

Represents a user's domain-scoped identity within a specific domain.

The User data type represents a user's scoped identity within a specific domain, such as an experience or OAuth application. It encapsulates a domain user ID alongside the domain metadata that uniquely identifies that user within that domain.

Unlike a numeric user ID alone, a User value carries its domain context, making it unambiguous across experiences and apps. It is the standard identifier for referencing users in new experience code and is available from Player.User.

Domain User IDs#

User IDs on Roblox are domain-scoped: a single account has a unique domain user ID for each experience or app it interacts with. This ensures that user activity in one experience cannot be correlated with activity in another by a third party using the user ID alone.

A domain user ID is an integer that is unique within a given domain (identified by DomainType and domain ID). Domain user IDs are guaranteed not to collide with existing global user IDs.

Serialization#

User supports round-trip string serialization via ToString() and fromString(). A User serialized with ToString() and deserialized with fromString() produces an identical value. The encoded string is stable, URL-safe, and compact. Use it when persisting or transmitting user identity across systems.

Users vs. Players#

A User represents persistent identity, not live server presence. It can reference any account in the domain, whether or not that user is currently connected. Use Player when you need the in-server instance.

Constructors 2#

fromIdCreates a User from a domain user ID within the current experience.
fromStringCreates a User from its serialized string form.

fromId(domainUserId: int64)#

Creates a new User from the given domain user ID, using the current experience as the domain. The ID must be a valid domain user ID (above the global user ID range).

NameTypeDefaultDescription
domainUserIdint64The domain-scoped user ID to construct the User from. Must be above the global user ID range.

fromString(userString: string)#

Deserializes a User from a string previously produced by ToString().

NameTypeDefaultDescription
userStringstringA string previously produced by ToString().

Properties 3#

Idint64The domain user ID, unique within this domain.
DomainTypeDomainTypeThe type of domain that this domain user ID belongs to.
DomainIdint64The identifier of the specific domain instance.

Id: int64#

The domain user ID for this user within the associated domain. This is an integer that uniquely identifies the user within the specific domain type and domain ID combination.

DomainType: DomainType#

The DomainType that identifies the kind of domain this domain user ID belongs to. Currently supported values are DomainType.EXPERIENCE and DomainType.OAUTH.

DomainId: int64#

The identifier of the specific domain instance that this user ID is scoped to. For DomainType.EXPERIENCE, this is the universe ID. For DomainType.OAUTH, this is the application ID.

Methods 1#

ToStringSerializes this User into a stable string representation.

ToString(): string#

Serializes this User into a string that encodes the domain type, domain ID, and domain user ID. The result is stable, URL-safe, and compact. Use this when storing or transmitting user identity.

The string can be converted back to a User via fromString().

Returns
  • string — A stable, URL-safe encoded string representing the domain type, domain ID, and domain user ID that can be deserialized back with fromString().