Skip to content

Path-based Functions ​

SetPath() ​

SetPath(player, path, value) → boolean

Sets a nested data value using dot notation with enhanced validation.

Parameters: player: Player, path: ValuePath, value: any
Returns: boolean - Success status

Example
lua
local success = PlayerState.SetPath(player, "Plot.Likes", 50)
if success then
    print("Plot likes updated")
end

PlayerState.SetPath(player, "Settings.MusicEnabled", false)
PlayerState.SetPath(player, "Stats.HighScore", 1200)

GetPath() ​

GetPath(player, path) → any

Gets a nested data value using dot notation with optimized performance. Automatically clones tables when AutoCloneTables is enabled in configuration.

Parameters: player: Player, path: ValuePath
Returns: any - The value, or nil if not found. Tables are cloned if AutoCloneTables is enabled.

Example
lua
local likes = PlayerState.GetPath(player, "Plot.Likes")
local musicEnabled = PlayerState.GetPath(player, "Settings.MusicEnabled")
local highScore = PlayerState.GetPath(player, "Stats.HighScore")

-- With AutoCloneTables enabled, tables are automatically cloned
local settings = PlayerState.GetPath(player, "Settings") -- Safe to modify
settings.NewOption = true -- Won't affect original if AutoCloneTables is true

Note

  • Optimized nested value retrieval with enhanced path caching system
  • When AutoCloneTables is enabled in config, table values are automatically deep cloned
  • Prevents accidental modification of internal data structures
  • Configure in PlayerStateConfig.Server.AutoCloneTables

Server-only paths

Paths under ServerOnlyRoots (for example Server.*) exist in profile.Data and work with SetPath / GetPath on the server, but are not present on the client Replica. See Server-only data.

PlayerState - High-Performance Roblox Data Management