Open Asterune
Players

Players

Contains connected Player instances and manages player lifecycle events.

Service
game:GetService("Players")
Inherits
Instance
Replication
Never

Behavior

Players contains the Player instances for connected players. Use its events to track joins and departures, and GetPlayers to query players already connected.

Summary

Members15
Properties5
Methods8
Events2

Properties

LocalPlayer

Players.LocalPlayer: Player = nil

The player associated with this client. Returns nil on the server.

MaxPlayers

Players.MaxPlayers: number = 50

The maximum number of players accepted by the server.

NumPlayers

Players.NumPlayers: number

The current number of connected players.

RespawnPolicy

Whether characters respawn automatically or require a script to load them.

RespawnTime

Players.RespawnTime: number = 5

The delay between character death and respawn, in seconds. Set to 0 for immediate respawn.

Methods

Chat

Players:Chat(message: string): ()

Displays a chat message associated with the supplied Part or character.

CreateLocalPlayer

Players:CreateLocalPlayer(userId: number, name: string): Player

Creates the local Player used by a standalone or test session.

GetExecutionGroup

Players:GetExecutionGroup(): ExecutionGroup?

Returns this instance if it is an ExecutionGroup. Otherwise returns the nearest ancestor ExecutionGroup, or nil when no group contains the instance.

GetPlayerByUserId

Players:GetPlayerByUserId(userId: number): Player?

Returns the connected Player with the specified user identifier, or nil if none exists.

GetPlayerFromCharacter

Players:GetPlayerFromCharacter(character: Model): Player?

Returns the player whose Character matches the supplied model, or nil if no player matches.

GetPlayers

Players:GetPlayers(): table

Returns a snapshot array of connected players.

RespawnPlayer

Players:RespawnPlayer(player: Player): boolean

Respawns the specified player immediately without waiting for RespawnTime.

TeamChat

Players:TeamChat(message: string): ()

Sends a message to the player's team chat.

Events

PlayerAdded

Players.PlayerAdded: RBXScriptSignal

Fires when a player joins. Passes the Player. Existing players do not trigger this event when a connection is added. Connect before querying GetPlayers, and make initialization safe to repeat.

PlayerRemoving

Players.PlayerRemoving: RBXScriptSignal

Fires before a player is removed. Passes the departing Player. Read or save required session state before removal.

Inherited members

Inherited47

Example

Luau
local Players = game:GetService("Players")
for _, player in Players:GetPlayers() do
  print(player.UserId)
end

Player · Humanoid · Teams · game