> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/scene-runtime/runtime-modules/players.md).

# Players

The `Players` module allows [scenes](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/scenes/README.md) to look for players in their environment and get information about their identity and [profiles](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/profiles/README.md).

```ts
const Players = require("~system/Players");
```

It contains the following methods and types:

* [`function getPlayersInScene`](#getPlayersInScene)
* [`function getConnectedPlayers`](#getPlayersInScene)
* [`function getPlayerData`](#getPlayerData)
* [`interface Player`](#Player)
* [`interface UserData`](#UserData)

### Methods

There's two methods in this module to discover players in the scene, and one to obtain their profiles.

**`getPlayersInScene`**

Returns a [`Player`](#Player) array, each with a `userId` that can be used in [getPlayerData](#getPlayerData).

```ts
interface Request {}

interface Response {
  players: Player[];
}

function getPlayersInScene(Request): Promise<Response>;
```

**`getConnectedPlayers`**

```ts
interface Request {}

interface Response {
  players: Player[];
}

function getConnectedPlayers(Request): Promise<Response>;
```

**`getPlayerData`**

Returns the [`UserData`](#UserData) for a user, if known for the given `userId`.

```ts
interface Request {
  // The user identifier, (for non-guests, their Ethereum address).
  userId: string;
}

interface Response {
  // The profile information for this user, if available.
  data?: UserData;
}

function getPlayerData(Request): Promise<Response>;
```

### Types

There's only two types in this module: [`Player`](#Player) and [`UserData`](#UserData).

**`Player`**

Holds a reference to a `userId`.

```ts
interface Player {
  // The user identifier, (for non-guests, their Ethereum address).
  userId: string;
}
```

**`UserData`**

Holds (possibly partial) information about a user, their identity and avatar.

World Explorers obtain this information through the [content system](https://github.com/decentraland/docs/tree/main/contributor/content/overview/README.md).

The [profile entity definition](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/profiles/README.md) details all of these fields and more. While the structure and keys of `UserData` are slightly different, the meaning of each field is the same.

```ts
export interface UserData {
  // The user identifier (i.e. their Ethereum address).
  userId: string;

  // A name to call them in the UI.
  displayName: string;

  // The Ethereum public key they sign with.
  publicKey?: string;

  // Whether they have web3 functionality enabled.
  hasConnectedWeb3: boolean;

  // The sequential version of this information, incremented on each user update.
  version: number;

  // Information about their avatar, if available.
  avatar?: {
    // Pointers to the assets required to render this avatar.
    bodyShape: string;
    wearables: string[];

    // Hex-encoded RGB/RGBA color tints for different body parts.
    skinColor: string;
    hairColor: string;
    eyeColor: string;

    // File identifiers for the "photos" of this avatar.
    snapshots?: {
      face256: string;
      body: string;
    };
  };
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/contributor/scene-runtime/runtime-modules/players.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
