# Player System

Players are the connected users of your game. You have access to a Player object for every connection in the current server. Players can be connect to a spawned character but always exist regardless.

Access this API with `Airship.Players`

```typescript
//Get Local Player
const myLocalPlayer = Game.localPlayer;

//Listen to players that aren't your local player
const nonLocalPlayers: Player[] = [];
Airship.Players.ObservePlayers((newPlayer) => { 
    if(!newPlayer.IsLocalPlayer()){
        nonLocalPlayers.push(newPlayer);
    }
});

//Get a players username from their spawned character
Airship.Characters.ObserveCharacters((character) => {
    //Let the server and client sync their data
    character.WaitForInit();
    print("New character username: " + character.player?.username);
});

//Loop through all players and access their characters
for(const player of Airship.Players.GetPlayers()) {
    const character = player.character;
    if(character) {
        //This player has a spawned character
        ...
    }
}
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.airship.gg/characters/player-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
