function PlayerDataStoreManager.new(P,z)local k=setmetatable(BaseObject.new(),PlayerDataStoreManager)k._robloxDataStore=P or error("\078\111 \114\111\098\108\111\120\068\097\116\097\083\116\111\114\101")k._keyGenerator=z or error("\078\111 \107\101\121\071\101\110\101\114\097\116\111\114")k._maid._savingConns=Maid.new()k._datastores={}k._removing={}k._pendingSaves=PendingPromiseTracker.new()k._removingCallbacks={}k._maid:GiveTask(Players.PlayerRemoving:Connect(function(P)if k._disableSavingInStudio then return end k:_removePlayerDataStore(P)end))game:BindToClose(function()if k._disableSavingInStudio then return end;(k:PromiseAllSaves()):Wait()end)return k end

function PlayerDataStoreManager.new(robloxDataStore, keyGenerator)
	local self = setmetatable(BaseObject.new(), PlayerDataStoreManager)

	self._robloxDataStore = robloxDataStore or error("No robloxDataStore")
	self._keyGenerator = keyGenerator or error("No keyGenerator")

	self._maid._savingConns = Maid.new()

	self._datastores = {} -- [player] = datastore
	self._removing = {} -- [player] = true
	self._pendingSaves = PendingPromiseTracker.new()
	self._removingCallbacks = {} -- [func, ...]

	self._maid:GiveTask(Players.PlayerRemoving:Connect(function(player)
		if self._disableSavingInStudio then
			return
		end

		self:_removePlayerDataStore(player)
	end))

	game:BindToClose(function()
		if self._disableSavingInStudio then
			return
		end

		self:PromiseAllSaves():Wait()
	end)

	return self
end
