Players API
Access cached player data with high performance.
Overview
The Players API provides access to cached player information. The cache is updated automatically in the background, making these functions very fast.
Player Object
All functions return player objects with this structure:
{
address = 0x..., -- Memory address (number)
name = "PlayerName", -- Player name (string)
health = 100, -- Current health (number)
max_health = 100, -- Maximum health (number)
distance = 50.5, -- Distance in studs (number)
position = { -- Position (table, may be nil)
x = 0,
y = 0,
z = 0
}
}Functions
get_all()
Get all players in the game.
Returns: table - Array of player objects
Example:
get_local()
Get the local player (you).
Returns: table or nil - Local player object
Example:
get_closest()
Get the closest player to you.
Returns: table or nil - Closest player object
Example:
get_by_name()
Find a player by name.
Parameters:
name(string) - Player name to search for
Returns: table or nil - Player object if found
Example:
filter_by_distance()
Get players within a certain distance.
Parameters:
max_distance(number) - Maximum distance in studs
Returns: table - Array of player objects
Example:
filter_by_health()
Get players within a health range.
Parameters:
min_health(number) - Minimum healthmax_health(number) - Maximum health
Returns: table - Array of player objects
Example:
Complete Examples
Player List Display
Closest Player Tracker
Threat Detector
Team Analyzer
Performance Notes
Cached data - All functions use cached data, very fast
Updated automatically - Cache updates ~10 times per second
No memory reads - Direct access to cached values
Safe to call frequently - Minimal performance impact
Tips
Always check for nil - Players may not exist
Check position exists - Not all players have position data
Cache results - Don't call get_all() multiple times per frame
Next Steps
Drawing API - Draw player information
Camera API - Project player positions to screen
Roblox API - Access detailed player data
Last updated