# Connection: player property

> The player read-only property of the Connection interface is the player ID of the player who opened the connection.

The **`player`** read-only property of the [`Connection`](/docs/room/connection) interface is the player ID of the player who opened the connection.

## Value

A string: the `sub` claim of the connection's token, or for a guest a guest ID that starts with `guest:`.

## Description

The player ID is the same for every connection the player opens, so it's what the room keys a player's things by: private state, entity ownership, [presence](/docs/room/presence) entries and bans. A room holds at most one open connection per player; see [One connection per player](/docs/room/connection#one-connection-per-player).

## Examples

### Giving the player a flag of its own

```ts
// flags.ts
import { defineRoom, defineSchema, entity } from "@irtio/room";

const Flag = entity("flag", { x: "f32", y: "f32" }, { writable: ["x", "y"], onOwnerLeave: "delete" });

export default defineRoom({
  schema: defineSchema({ entities: [Flag] }),
  onJoin(room, connection) {
    if (room.entities.ownedBy(connection.player, Flag).next().done) {
      room.entities.create(Flag, {}, { owner: connection.player });
    }
  },
});
```

## See also

- [`Entities.ownedBy()`](/docs/room/entities/ownedby)
- [Ownership](/docs/room/guides/ownership)
