Skip to content

User

Class ยท server and client scripts

User is the account identity of a player entity: its user id, its display name, and its round trip time to the server. Read it through player.User; scripts cannot write through it. The player's character is player.Avatar.

Example

-- Server script.
Component.User.Added:Connect(function(player: Entity)
    local user = player.User
    if user then
        print(user.DisplayName, user.Id, Players.Get(user.Id) == player)
    end
end)

Id

PropertyRead only
Id: number

Id is the account user id of this player.

A test player from a Studio playtest with several players, or from luduvo-run --players, has no account: Playerk gets user id 4503599627370496 + k for k from 1 to 8, so a test player's Id is between 4503599627370497 and 4503599627370504.

DisplayName

PropertyRead only
DisplayName: string

DisplayName is the name on the player's nametag and in the player list. It reads the entity's DisplayName component, or the entity's Name when that is empty.

RoundTrip

PropertyRead only
RoundTrip: number

RoundTrip is the round trip time between the server and this player, in milliseconds, smoothed over recent packets. It reads 0 on clients.