User

Constructors

NameDescription
Player.UserThe typical way gameplay code obtains a User - a read-only property on Player that returns the User representing that player's domain-scoped identity within the current experience. There's no need to construct one manually for a connected player.
fromId(domainUserId: int64):UserCreates a User from a domain user ID within the current experience's domain. Useful for referencing an account when there is no live Player instance, for example one previously saved to a DataStore.
fromString(userString: string):UserDeserializes a User from a string previously produced by User:ToString().

Code Snippet

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    local user = player.User -- User is provided by Player, not constructed directly
    print(user.Id, user.DomainType, user.DomainId)

    local serialized = user:ToString()
    local sameUser = User.fromString(serialized)
    print(sameUser.Id == user.Id) --> true
end)

Properties

NameTypeDescription
Idint64The domain user ID for this user within the associated domain.
DomainTypeDomainTypeThe DomainType that identifies the kind of domain this domain user ID belongs to. Currently supports EXPERIENCE and OAUTH.
DomainIdint64The identifier of the specific domain instance that this user ID is scoped to. For the EXPERIENCE domain type this is the universe ID; for OAUTH it is the application ID.

Methods

NameParametersReturnsDescription
ToString():stringVoidstringSerializes this User into a stable, URL-safe string that encodes the domain type, domain ID, and domain user ID. The result can be turned back into a User with User.fromString().