We use cookies on this site to enhance your user experience

Individual Player Data Stores

Individual Player Data Stores

Sep 05 2018, 1:26 PM PST

This code sample features a simple way to work with per-player data stores called “Stats” and “Resources.”

local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

local function onPlayerAdded(player)
	local scope = "Player_" .. player.UserId
	local playerStats = DataStoreService:GetDataStore("Stats", scope)
	local playerResources = DataStoreService:GetDataStore("Resources", scope)
	-- GetAsync()/UpdateAsync() can now be called on the 'Stats' and 'Resources' data stores