How to use DataStore2 - Data Store caching and data loss prevention

The problem is my script is for everyone

Okay I will try that @Grargor Thanks!

It is not working still or else it would have a gold leaderstats on the side and it does not.

	local dataGold = DataStore2("Gold", plr)
	local folder = Instance.new("Folder",plr)
	folder.Name = "leaderstats"
	
	local gold = Instance.new("IntValue", folder)
	gold.Name = "Gold"
	local initialGold = 100
	gold.Value = dataGold:Get(initialGold)
	
	gold.Changed:Connect(function()
		dataGold:Set(gold.Value)
		
		player.CharacterAdded:Connect(function(character)
			character:WaitForChild("Humanoid").Died:connect(function()
				
				local tag = character.Humanoid:FindFirstChild("creator")
				
				if tag ~= nil then
					
					if tag.Value ~= nil then
						
						local stats = tag.Value:WaitForChild("leaderstats")
						
						stats["Gold"].Value = stats ["Gold"].Value + 150
						
					end
					
				end

Is that your entire script?

If so, the script is erroring because there are formatting issues. Please go to your “View” tab at the top of Studio and enable the “Output” and “Script Analysis” windows. Script Analysis will inform you of the formatting issues. The Output window will print any errors when you press the “Play In Studio” button.

At this point, this is not a DataStore2 issue. This is a scripting support issue. Any further questions about your script should probably be posted in a separate post.

That is the Error it showed, but there is no red lines in the script.

1 Like

Hi, how I can connect DataStore2 to fetch game’s existed datastore with player userid key?

is there any limit for number of keys that can be saved in DataStore2 in a game?

Does this module also use GlobalDataStores
if so how can I access the table by using the GlobalDataStoresFunction
I meant the table of the player’s stats

You should be using one master key, but aside from that, not really. If one key ends up taking a LOOOOT of data, it can limit the rest, but unless you’re doing something insane you’ll be fine.

1 Like

Is there a way to access all the information(like tutorials) for Datastore2? I think that the data saving is excellent, but I just problems learning all the functions for it. If not that’s fine as well. Thanks! :happy1:

Do you mean documentation? If so then it is @
https://kampfkarren.github.io/Roblox/

1 Like

I’m an idiot for not seeing the arrow at the bottom of my phone. Thank you!

I just thought of a big brain move, or possibly small brain move lol…what if you use both regular datastores and datastores 2 at the same time?

Hello! I’m using datastore2 a lot and is wonderful but I still with this problem I don’t know what else to do please help :pray:

From what I can tell using both of them is not practical, the only time you should use datastore2 and a normal datastore is when you have a leaderboard of some sort which will need the normal datastore for it to work, as I don’t think DataStore2 is compatible with a leaderboard. If you don’t plan to have a leaderboard then I would say stick to dataStore2 as it is really reliable. I’m no expert with datastores, and or scripting for that matter, but I do think using both datastores in a game is just unnecessary and wouldn’t be good for the server especially if the game gets a lot of attraction.

Does anyone know what’s up with this error, I get it when I try buying a developer product that’s suppose to Incremente my coins.

Error: [ServerScriptService.DataStore2:479: DataStore2() API call expected {string dataStoreName, Instance player}, got {string, nil}

Script for Dev Product:

local MarketplaceService = game:GetService(“MarketplaceService”)
local SeverScriptService = game:GetService(“ServerScriptService”)
local DataStore2 = require(SeverScriptService:WaitForChild(“DataStore2”))
local DrachmaId1 = 1020030204 --1000 Drachma
local DrachmaId2 = 1020143993 --5000 drachma
local DrachmaId3 = 1020148147 --10,000 drachma
local DrachmaId4 = 1020151919 --20,000 drachma
local DrachmaId5 = 1020150864 – 40,000 drachma
local Players = game:GetService(“Players”)
local Pler = Players.LocalPlayer

DataStore2.Combine(“DATA”, “CoinStore”)
local function processReceipt(receiptInfo, Plr)
local player = game:GetService(“Players”):GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet

end
 if receiptInfo.ProductId == DrachmaId1 then
	
print(player.Name.. "just bought" .. receiptInfo.ProductId)
	
local CoinStore = DataStore2("CoinStore", Pler)
	CoinStore:Increment(1000)
--player.Cosas.Coins.Value = player.Cosas.Coins.Value + 1000

end

if receiptInfo.ProductId == DrachmaId2 then
	
print(player.Name.. "just bought" .. receiptInfo.ProductId)
	local CoinStore = DataStore2("CoinStore", Pler)
	CoinStore:Increment(5000)
--player.Cosas.Coins.Value = player.Cosas.Coins.Value + 5000

end

if receiptInfo.ProductId == DrachmaId3 then
	
print(player.Name.. "just bought" .. receiptInfo.ProductId)
	
	local CoinStore = DataStore2("CoinStore", Pler)
	CoinStore:Increment(10000)
--player.Cosas.Coins.Value = player.Cosas.Coins.Value + 10000

end

if receiptInfo.ProductId == DrachmaId4 then
	
print(player.Name.. "just bought" .. receiptInfo.ProductId)
	local CoinStore = DataStore2("CoinStore", Pler)
	CoinStore:Increment(20000)
--player.Cosas.Coins.Value = player.Cosas.Coins.Value + 20000

end

if receiptInfo.ProductId == DrachmaId5 then
	
print(player.Name.. "just bought" .. receiptInfo.ProductId)
	local CoinStore = DataStore2("CoinStore", Pler)
	CoinStore:Increment(45000)
player.Cosas.Coins.Value = player.Cosas.Coins.Value + 45000

end

return Enum.ProductPurchaseDecision.PurchaseGranted
end

MarketplaceService.ProcessReceipt = processReceipt

Your error is here. Please read through your code and make sure you are using the API correctly.

1 Like

Nvm I figured it out. I changed the “Pler”-which equaled game.Players.LocalPlayer. To “player”(game:GetService(“Players”):GetPlayerByUserId(receiptInfo.PlayerId)). That seems to have fixed it.

1 Like

I am trying to figure out how to make a decent inventory system using Datastore2.
and i`m going back and forward trying to figure out what the best way is.

inventory background info and wishlist
  • 27 player inventory slots
  • bankslots start at 54 (2x27) → maybe upgradable later
  • max stack count difers between bank and inventory
  • ability to insert items → example (inventory:insert({“sword”,1,“shield”,1}))(and error if it fails)
  • ability to destroy items-> example (inventory:Destroy({“sword”,1,“shield”,1}))(and error if it fails)
  • ability to split stacks
  • ability to transfer stacks between inventorys(bank,backpack) but alsow between slots

this is what I am trying currently

warning long scripy
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local ServerStorage = game:GetService("ServerStorage")
local ContentProvider = game:GetService("ContentProvider")

DataStore2 = require(script.DataStore2)
Inven = require(script.Inventory)
-------------------------------------
local datastores ={
	"WorldId",
	"X",
	"Y",
	"Z",

	"respawn",
	"died",

	"BrawlingXp",
	"ArcheryXp",
	"CastingXp",
	"RobustnessXp",
	"ArmorXp",
	"StrengthXp",

	"SmithingXp",
	"FletchingXp",
	"EnchantingXp",
	"MiningXp",
	"WoodcuttingXp",
	"FiremakingXp",

	"FishingXp",
	"FarmingXp",
	"HerbloreXp",
	"CookingXp",
	"CraftingXp",
	"WorshipingXp",

	"AgilityXp",
	"ThievingXp",
	"SlayingXp",
	"HuntingXp",
	"SummoningXp",
	"ConstructingXp",

	"QuestsProgress",

	"EqHead",	
	"EqBack",	
	"EqNeck",	 
	"EqAmmunition",
	"EqMain_Tool",	 
	"EqTorso",	
	"EqOff_Tool",
	"EqGloves",	
	"EqLegs",	 
	"EqRing",
	"EqFeet",	


	"Bac1",--backpack slot 1 item name
	"Bac1Q", -- quantity in backpackslot 1
	"Bac2",
	"Bac2Q",
	"Bac3",
	"Bac3Q",
	"Bac4",
	"Bac4Q",
	"Bac5",
	"Bac5Q",
	"Bac6",
	"Bac6Q",
	"Bac7",
	"Bac7Q",
	"Bac8",
	"Bac8Q",
	"Bac9",
	"Bac9Q",
	"Bac10",
	"Bac10Q",
	"Bac11",
	"Bac11Q",
	"Bac12",
	"Bac12Q",
	"Bac13",
	"Bac13Q",
	"Bac14",
	"Bac14Q",
	"Bac15",
	"Bac15Q",
	"Bac16",
	"Bac16Q",
	"Bac17",
	"Bac17Q",
	"Bac18",
	"Bac18Q",
	"Bac19",
	"Bac19Q",
	"Bac20",
	"Bac20Q",
	"Bac21",
	"Bac21Q",
	"Bac22",
	"Bac22Q",
	"Bac23",
	"Bac23Q",
	"Bac24",
	"Bac24Q",
	"Bac25",
	"Bac25Q",
	"Bac26",
	"Bac26Q",
	"Bac27",
	"Bac27Q",

	"Ban1",--itemname in bankslot 1
	"Ban1Q",--quantity of items in bankslot 1 
	"Ban2",
	"Ban2Q",
	"Ban3",
	"Ban3Q",
	"Ban4",
	"Ban4Q",
	"Ban5",
	"Ban5Q",
	"Ban6",
	"Ban6Q",
	"Ban7",
	"Ban7Q",
	"Ban8",
	"Ban8Q",
	"Ban9",
	"Ban9Q",
	"Ban10",
	"Ban10Q",
	"Ban11",
	"Ban11Q",
	"Ban12",
	"Ban12Q",
	"Ban13",
	"Ban13Q",
	"Ban14",
	"Ban14Q",
	"Ban15",
	"Ban15Q",
	"Ban16",
	"Ban16Q",
	"Ban17",
	"Ban17Q",
	"Ban18",
	"Ban18Q",
	"Ban19",
	"Ban19Q",
	"Ban20",
	"Ban20Q",
	"Ban21",
	"Ban21Q",
	"Ban22",
	"Ban22Q",
	"Ban23",
	"Ban23Q",
	"Ban24",
	"Ban24Q",
	"Ban25",
	"Ban25Q",
	"Ban26",
	"Ban26Q",
	"Ban27",
	"Ban27Q",
	"Ban28",
	"Ban28Q",
	"Ban29",
	"Ban29Q",
	"Ban30",
	"Ban30Q",
	"Ban31",
	"Ban31Q",
	"Ban32",
	"Ban32Q",
	"Ban33",
	"Ban33Q",
	"Ban34",
	"Ban34Q",
	"Ban35",
	"Ban35Q",
	"Ban36",
	"Ban36Q",
	"Ban37",
	"Ban37Q",
	"Ban38",
	"Ban38Q",
	"Ban39",
	"Ban39Q",
	"Ban40",
	"Ban40Q",
	"Ban41",
	"Ban41Q",
	"Ban42",
	"Ban42Q",
	"Ban43",
	"Ban43Q",
	"Ban44",
	"Ban44Q",
	"Ban45",
	"Ban45Q",
	"Ban46",
	"Ban46Q",
	"Ban47",
	"Ban47Q",
	"Ban48",
	"Ban48Q",
	"Ban49",
	"Ban49Q",
	"Ban50",
	"Ban50Q",
	"Ban51",
	"Ban51Q",
	"Ban52",
	"Ban52Q",
	"Ban53",
	"Ban53Q",
	"Ban54",
	"Ban54Q",
}
-------------------------------------------
DataStore2.Combine("DATA",
	"WorldId",
	"X",
	"Y",
	"Z",

	"respawn",
	"died",

	"BrawlingXp",
	"ArcheryXp",
	"CastingXp",
	"RobustnessXp",
	"ArmorXp",
	"StrengthXp",
	"SmithingXp",
	"FletchingXp",
	"EnchantingXp",
	"MiningXp",
	"WoodcuttingXp",
	"FiremakingXp",
	"FishingXp",
	"FarmingXp",
	"HerbloreXp",
	"CookingXp",
	"CraftingXp",
	"WorshipingXp",
	"AgilityXp",
	"ThievingXp",
	"SlayingXp",
	"HuntingXp",
	"SummoningXp",
	"ConstructingXp",

	"QuestsProgress",

	"EqHead",	
	"EqBack",	
	"EqNeck",	 
	"EqAmmunition",
	"EqMain_Tool",	 
	"EqTorso",	
	"EqOff_Tool",
	"EqGloves",	
	"EqLegs",	 
	"EqRing",
	"EqFeet",

	"Bac1",
	"Bac1Q",
	"Bac2",
	"Bac2Q",
	"Bac3",
	"Bac3Q",
	"Bac4",
	"Bac4Q",
	"Bac5",
	"Bac5Q",
	"Bac6",
	"Bac6Q",
	"Bac7",
	"Bac7Q",
	"Bac8",
	"Bac8Q",
	"Bac9",
	"Bac9Q",
	"Bac10",
	"Bac10Q",
	"Bac11",
	"Bac11Q",
	"Bac12",
	"Bac12Q",
	"Bac13",
	"Bac13Q",
	"Bac14",
	"Bac14Q",
	"Bac15",
	"Bac15Q",
	"Bac16",
	"Bac16Q",
	"Bac17",
	"Bac17Q",
	"Bac18",
	"Bac18Q",
	"Bac19",
	"Bac19Q",
	"Bac20",
	"Bac20Q",
	"Bac21",
	"Bac21Q",
	"Bac22",
	"Bac22Q",
	"Bac23",
	"Bac23Q",
	"Bac24",
	"Bac24Q",
	"Bac25",
	"Bac25Q",
	"Bac26",
	"Bac26Q",
	"Bac27",
	"Bac27Q",

	"Ban1",
	"Ban1Q",
	"Ban2",
	"Ban2Q",
	"Ban3",
	"Ban3Q",
	"Ban4",
	"Ban4Q",
	"Ban5",
	"Ban5Q",
	"Ban6",
	"Ban6Q",
	"Ban7",
	"Ban7Q",
	"Ban8",
	"Ban8Q",
	"Ban9",
	"Ban9Q",
	"Ban10",
	"Ban10Q",
	"Ban11",
	"Ban11Q",
	"Ban12",
	"Ban12Q",
	"Ban13",
	"Ban13Q",
	"Ban14",
	"Ban14Q",
	"Ban15",
	"Ban15Q",
	"Ban16",
	"Ban16Q",
	"Ban17",
	"Ban17Q",
	"Ban18",
	"Ban18Q",
	"Ban19",
	"Ban19Q",
	"Ban20",
	"Ban20Q",
	"Ban21",
	"Ban21Q",
	"Ban22",
	"Ban22Q",
	"Ban23",
	"Ban23Q",
	"Ban24",
	"Ban24Q",
	"Ban25",
	"Ban25Q",
	"Ban26",
	"Ban26Q",
	"Ban27",
	"Ban27Q",
	"Ban28",
	"Ban28Q",
	"Ban29",
	"Ban29Q",
	"Ban30",
	"Ban30Q",
	"Ban31",
	"Ban31Q",
	"Ban32",
	"Ban32Q",
	"Ban33",
	"Ban33Q",
	"Ban34",
	"Ban34Q",
	"Ban35",
	"Ban35Q",
	"Ban36",
	"Ban36Q",
	"Ban37",
	"Ban37Q",
	"Ban38",
	"Ban38Q",
	"Ban39",
	"Ban39Q",
	"Ban40",
	"Ban40Q",
	"Ban41",
	"Ban41Q",
	"Ban42",
	"Ban42Q",
	"Ban43",
	"Ban43Q",
	"Ban44",
	"Ban44Q",
	"Ban45",
	"Ban45Q",
	"Ban46",
	"Ban46Q",
	"Ban47",
	"Ban47Q",
	"Ban48",
	"Ban48Q",
	"Ban49",
	"Ban49Q",
	"Ban50",
	"Ban50Q",
	"Ban51",
	"Ban51Q",
	"Ban52",
	"Ban52Q",
	"Ban53",
	"Ban53Q",
	"Ban54",
	"Ban54Q"
)
-end of combine-----------------------------


function callRemote(player, Subject, value)  -- comunication towards client
	ReplicatedStorage.Core.Remotes.RemoteEvent:FireClient(player,Subject,value)
end



Players.PlayerAdded:Connect(function(player) ---- main setup 
	for i,v in pairs (datastores) do
		getfenv()[v] = DataStore2(v, player)
		local value = getfenv()[v]:Get(0)
		callRemote(player,v,value)

		getfenv()[v]:OnUpdate(function (value)callRemote(player,v,value)end)

	end
	WorldId = DataStore2("WorldId", player)
	WorldId:BeforeSave(function()
		WorldId:Set(game.PlaceId,player)
	end)
end)

function OnServerEvent(player,Subject,...)
	print(player,Subject,...)
	if Subject == "invenswap" then
		Inven.invenswap (player,...)
	end
end


ReplicatedStorage.Core.Remotes.RemoteEvent.OnServerEvent:Connect(OnServerEvent)```
Itemdictionary just in case, skills have something similary
	["Bronze_Coin"] = {
		["Description"] = "the main human currency",
		["BackpackStackSize"] = 1000,
		["BankStackSize"] = 10000,
		["Value"] = 1,
		["ModelId"] = 0,
		["ImageId"] = 0,
	},
	["Copper_Coin"] = {
		["Description"] = "the main human currency",
		["BackpackStackSize"] = 1000,
		["BankStackSize"] = 10000,
		["Value"] = 100,
		["ModelId"] = 0,
		["ImageId"] = 4230412396,
	},
	["Silver_Coin"] = {
		["Description"] = "the main human currency",
		["BackpackStackSize"] = 1000,
		["BankStackSize"] = 10000,
		["Value"] = 1000,
		["ModelId"] = 0,
		["ImageId"] = 0,
	},

	["Gold_Coin"] = {
		["Description"] = "the main human currency",
		["BackpackStackSize"] = 1000,
		["BankStackSize"] = 10000,
		["Value"] = 10000,
		["ModelId"] = 0,
		["ImageId"] = 0,
	},
	["Sword"] = {
		["Description"] = "a training sword",
		["BackpackStackSize"] = 1,
		["BankStackSize"] = 1,
		["Value"] = 0,
		["ModelId"] = 0,
		["ImageId"] = 711844382,
	},
}

MetaTable = { __index = function(table, key)
	return {["Description"] = "Item info is missing",
	["BackpackStackSize"] = "inf",
	["BankStackSize"] = "inf",
	["Value"] = 0,
	["ModelId"] = 0,
	["ImageId"] = 175158448}
end}

setmetatable(ItemDictionary,MetaTable)

return ItemDictionary```

for the XP part this works like a charm, easy to understand and to implement
but as mentioned above i am hesitant about the inventory system

I have played with a alternatives
keep in mind that I didn’t save my alternatives and this might have bugs

Alternative 1, tables
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local ServerStorage = game:GetService("ServerStorage")
local ContentProvider = game:GetService("ContentProvider")
local HttpService = game:GetService("HttpService")


DataStore2 = require(script.DataStore2)
Inven = require(script.Inventory)
-------------------------------------
local datastores ={
	"WorldId",
	"X",
	"Y",
	"Z",

	"respawn",
	"died",

	"BrawlingXp",
	"ArcheryXp",
	"CastingXp",
	"RobustnessXp",
	"ArmorXp",
	"StrengthXp",

	"SmithingXp",
	"FletchingXp",
	"EnchantingXp",
	"MiningXp",
	"WoodcuttingXp",
	"FiremakingXp",

	"FishingXp",
	"FarmingXp",
	"HerbloreXp",
	"CookingXp",
	"CraftingXp",
	"WorshipingXp",

	"AgilityXp",
	"ThievingXp",
	"SlayingXp",
	"HuntingXp",
	"SummoningXp",
	"ConstructingXp",

	"QuestsProgress",

}
-------------------------------------------
DataStore2.Combine("DATA",
	"WorldId",
	"X",
	"Y",
	"Z",

	"respawn",
	"died",

	"BrawlingXp",
	"ArcheryXp",
	"CastingXp",
	"RobustnessXp",
	"ArmorXp",
	"StrengthXp",
	"SmithingXp",
	"FletchingXp",
	"EnchantingXp",
	"MiningXp",
	"WoodcuttingXp",
	"FiremakingXp",
	"FishingXp",
	"FarmingXp",
	"HerbloreXp",
	"CookingXp",
	"CraftingXp",
	"WorshipingXp",
	"AgilityXp",
	"ThievingXp",
	"SlayingXp",
	"HuntingXp",
	"SummoningXp",
	"ConstructingXp",

	"QuestsProgress",

	"Backpack",
	"Bank",
	"Equiped"
)
------------------------------


function callRemote(player, Subject, value)  -- comunication towards client
	ReplicatedStorage.Core.Remotes.RemoteEvent:FireClient(player,Subject,value)
end



Players.PlayerAdded:Connect(function(player) ---- main setup 
	for i,v in pairs (datastores) do
		getfenv()[v] = DataStore2(v, player)
		local value = getfenv()[v]:Get(0)
		callRemote(player,v,value)

		getfenv()[v]:OnUpdate(function (value)callRemote(player,v,value)end)

	end
	WorldId = DataStore2("WorldId", player)
	WorldId:BeforeSave(function()
		WorldId:Set(game.PlaceId,player)
	end)

	local DefaultBackpack = {
		["1"]={["item"] = "",["Quantity"] = 0},
		["2"]={["item"] = "",["Quantity"] = 0},
		["3"]={["item"] = "",["Quantity"] = 0},
		["4"]={["item"] = "",["Quantity"] = 0},
		["5"]={["item"] = "",["Quantity"] = 0},
		["6"]={["item"] = "",["Quantity"] = 0},
		["7"]={["item"] = "",["Quantity"] = 0},
		["8"]={["item"] = "",["Quantity"] = 0},
		["9"]={["item"] = "",["Quantity"] = 0},
		["10"]={["item"] = "",["Quantity"] = 0},
		["11"]={["item"] = "",["Quantity"] = 0},
		["12"]={["item"] = "",["Quantity"] = 0},
		["13"]={["item"] = "",["Quantity"] = 0},
		["14"]={["item"] = "",["Quantity"] = 0},
		["15"]={["item"] = "",["Quantity"] = 0},
		["16"]={["item"] = "",["Quantity"] = 0},
		["17"]={["item"] = "",["Quantity"] = 0},
		["18"]={["item"] = "",["Quantity"] = 0},
		["19"]={["item"] = "",["Quantity"] = 0},
		["20"]={["item"] = "",["Quantity"] = 0},
		["21"]={["item"] = "",["Quantity"] = 0},
		["22"]={["item"] = "",["Quantity"] = 0},
		["23"]={["item"] = "",["Quantity"] = 0},
		["24"]={["item"] = "",["Quantity"] = 0},
		["25"]={["item"] = "",["Quantity"] = 0},
		["26"]={["item"] = "",["Quantity"] = 0},
		["27"]={["item"] = "",["Quantity"] = 0},
	}

	local Backpack = DataStore2("Backpack", player)
	backpackinv2 = Backpack:Get(DefaultBackpack)
	--print(backpackinv2)
	--Backpack:Set(DefaultBackpack)
	callRemote(player,backpackinv2)
	Backpack:OnUpdate(function (value)callRemote(player,backpackinv2)end)

	local DefaultBank = {
		["1"]={["item"] = "",["Quantity"] = 0},
		["2"]={["item"] = "",["Quantity"] = 0},
		["3"]={["item"] = "",["Quantity"] = 0},
		["4"]={["item"] = "",["Quantity"] = 0},
		["5"]={["item"] = "",["Quantity"] = 0},
		["6"]={["item"] = "",["Quantity"] = 0},
		["7"]={["item"] = "",["Quantity"] = 0},
		["8"]={["item"] = "",["Quantity"] = 0},
		["9"]={["item"] = "",["Quantity"] = 0},
		["10"]={["item"] = "",["Quantity"] = 0},
		["11"]={["item"] = "",["Quantity"] = 0},
		["12"]={["item"] = "",["Quantity"] = 0},
		["13"]={["item"] = "",["Quantity"] = 0},
		["14"]={["item"] = "",["Quantity"] = 0},
		["15"]={["item"] = "",["Quantity"] = 0},
		["16"]={["item"] = "",["Quantity"] = 0},
		["17"]={["item"] = "",["Quantity"] = 0},
		["18"]={["item"] = "",["Quantity"] = 0},
		["19"]={["item"] = "",["Quantity"] = 0},
		["20"]={["item"] = "",["Quantity"] = 0},
		["21"]={["item"] = "",["Quantity"] = 0},
		["22"]={["item"] = "",["Quantity"] = 0},
		["23"]={["item"] = "",["Quantity"] = 0},
		["24"]={["item"] = "",["Quantity"] = 0},
		["25"]={["item"] = "",["Quantity"] = 0},
		["26"]={["item"] = "",["Quantity"] = 0},
		["27"]={["item"] = "",["Quantity"] = 0},
		["28"]={["item"] = "",["Quantity"] = 0},
		["29"]={["item"] = "",["Quantity"] = 0},
		["30"]={["item"] = "",["Quantity"] = 0},
		["31"]={["item"] = "",["Quantity"] = 0},
		["32"]={["item"] = "",["Quantity"] = 0},
		["33"]={["item"] = "",["Quantity"] = 0},
		["34"]={["item"] = "",["Quantity"] = 0},
		["35"]={["item"] = "",["Quantity"] = 0},
		["36"]={["item"] = "",["Quantity"] = 0},
		["37"]={["item"] = "",["Quantity"] = 0},
		["38"]={["item"] = "",["Quantity"] = 0},
		["39"]={["item"] = "",["Quantity"] = 0},
		["40"]={["item"] = "",["Quantity"] = 0},
		["41"]={["item"] = "",["Quantity"] = 0},
		["42"]={["item"] = "",["Quantity"] = 0},
		["43"]={["item"] = "",["Quantity"] = 0},
		["44"]={["item"] = "",["Quantity"] = 0},
		["45"]={["item"] = "",["Quantity"] = 0},
		["46"]={["item"] = "",["Quantity"] = 0},
		["47"]={["item"] = "",["Quantity"] = 0},
		["48"]={["item"] = "",["Quantity"] = 0},
		["49"]={["item"] = "",["Quantity"] = 0},
		["50"]={["item"] = "",["Quantity"] = 0},
		["51"]={["item"] = "",["Quantity"] = 0},
		["52"]={["item"] = "",["Quantity"] = 0},
		["53"]={["item"] = "",["Quantity"] = 0},
		["54"]={["item"] = "",["Quantity"] = 0},
	}
	local Bank = DataStore2("Bank", player)
	Bankinv2 = Bank:Get(DefaultBank)
	--print(backpackinv2)
	--Bank:Set(DefaultBank)
	callRemote(player,Bankinv2)
	Bank:OnUpdate(function (value)callRemote(player,Bankinv2)end)

	local DefaultEquiped ={
		["Head" ]= "",
		["Back" ]= "",
		["Neck" ]= "",
		["Ammunition"]= "",
		["Main_Tool" ]= "",
		["Torso" ]= "",
		["Off_Tool"]= "",
		["Gloves" ]= "",
		["Legs"]= "",
		["Ring"]= "",
		["Feet"]= "",
	}

	local Equiped = DataStore2("Equiped", player)
	Equipedinv2 = Equiped:Get(DefaultEquiped)
	--print(Equipedinv2)
	--Equiped:Set(DefaultEquiped)
	callRemote(player,Equipedinv2)
	Bank:OnUpdate(function (value)callRemote(player,Equipedinv2)end)

end)

function OnServerEvent(player,Subject,...)
	print(player,Subject,...)
	if Subject == "invenswap" then
		Inven.invenswap (player,...)
	end
end


ReplicatedStorage.Core.Remotes.RemoteEvent.OnServerEvent:Connect(OnServerEvent)

my question is :
based on Datastore2. what would be the best way to manage a inventory system.

i know other people have simulair issues,
ended up reading most of the messages here, watching the alvin blox video and RDC 2019
going to the github yet my doubt prevails

Just a question, do you need to add a Players.PlayerRemoved function for the data to save on leave. I’m unsure of when else data other than when you specifically update it. If that makes any sense.