Appearance
Initialization Functions ​
Init() ​
Init(player, existingData?)
Initializes PlayerState for a player. Must be called when a player joins.
Parameters:
player: Player- The player to initializeexistingData?: PlayerData- Optional existing data (not currently supported)
Returns: boolean - Success status
Example
lua
local success = PlayerState.Init(player)
if success then
print("Player data loaded successfully")
else
warn("Failed to load player data")
-- Player will be kicked automatically
endNotes:
- Automatically loads data from ProfileStore and creates Replica for client sync (player Replica data omits roots listed in
ServerOnlyRoots) - Shared session uses a separate SharedSession Replica when configured; see Shared Session
- Handles ProfileStore session management with automatic leaderstats integration
- Enhanced data validation and cleanup
- Player will be kicked if data fails to load