Players¶
System · Players · server and client scripts
Players looks up connected players and their characters, checks admin status, and disconnects players. Subscribe to player and character lifecycle events through Component.User.Added:Connect(...), Component.User.Removed:Connect(...), and Component.Character.Added:Connect(...).
All¶
All returns an array of every player currently in the place.
Local¶
Local is the local player on the client, or nil before the local player reaches the client. Reading Players.Local on the server raises an error.
Errors (1)
| Error | When |
|---|---|
Local can only be written from a client script |
Written from a server script. |
Of¶
Of returns the player that owns entity (a player or character entity), or nil if none owns it.
Example
IsAdmin¶
IsAdmin returns whether player has place administrator permissions.
Example
Get¶
Get returns the player with the given user ID, or nil.
Example
Kick¶
Kick disconnects a player from the server and shows them the reason.
Example
Errors (1)
| Error | When |
|---|---|
Kick can only be called from the server |
Called from a client script. |
Friends¶
FriendStatus¶
FriendStatus returns the relation of the local player to another player, one of the FriendStatus strings. Before the first relation reply arrives, it returns "NotFriend". Only client scripts may call it.
Example
Errors (1)
| Error | When |
|---|---|
FriendStatus can only be called from a client script |
Called from a server script. |
FriendStatusChanged¶
FriendStatusChanged fires with a player and the new FriendStatus when the local player's relation to that player changes.
Example
Errors (1)
| Error | When |
|---|---|
FriendStatusChanged can only be written from a client script |
Written from a server script. |
AreFriends¶
AreFriends returns whether two players are friends and neither has blocked the other. It returns false when both arguments refer to the same player. Only server scripts may call it.
Example
Errors (1)
| Error | When |
|---|---|
AreFriends can only be called from the server |
Called from a client script. |
FriendshipChanged¶
FriendshipChanged fires when a friendship between two present players begins or ends, passing both players and whether they are now friends. Only server scripts may use it.
Example
Errors (1)
| Error | When |
|---|---|
FriendshipChanged can only be written from the server |
Written from a client script. |
Badge¶
Badge returns the platform badge of a player as a string, or nil when the player has none. The platform decides which strings exist; the engine passes them through unchanged. Both server and client scripts may call it.
Example
BadgeIcon¶
BadgeIcon returns the decimal texture asset ID for a platform badge name ("cadet", "specialist", or "commander"), or nil for an unknown name.
Example
BadgeChanged¶
BadgeChanged fires with a player and their new Badge string, or nil when the badge is cleared, for each present player whose badge changed.