Description
The LocalPlayer
property provides access to the local player's statistics within the current game session. This property is part of the Sandbox.Services.Stats
class, which facilitates the management and retrieval of game-related statistics. The statistics are defined by the game's author and can be used to track various metrics such as player actions, performance, and other relevant data.
Usage
To access the local player's statistics, use the LocalPlayer
property from the Stats
class. This property is static and can be accessed directly without instantiating the Stats
class.
var playerStats = Stats.LocalPlayer;
// Use playerStats to access specific statistics for the local player
Example
// Example of accessing local player stats
var playerStats = Stats.LocalPlayer;
// Example usage: Accessing a specific stat
var score = playerStats.GetStat("score");
// Example usage: Incrementing a stat
playerStats.IncrementStat("kills", 1);