Hand-written by Joseph San Nicolas, Roblox Developer
User
Constructors
| Name | Description |
| Player.User | The 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):User | Creates 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):User | Deserializes 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
| Name | Type | Description |
| Id | int64 | The domain user ID for this user within the associated domain. |
| DomainType | DomainType | The DomainType that identifies the kind of domain this domain user ID belongs to. Currently supports EXPERIENCE and OAUTH. |
| DomainId | int64 | The 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
| Name | Parameters | Returns | Description |
| ToString():string | Void | string | Serializes 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(). |