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

I made a plugin for this module its still in progress since its my most complex plugin i made. But how it works u just connect to a datastore “Dataname/userid” and press connect button.
On the buttom of the connect screen there is the current datastore key but you can use your desired key like 1,2,3…etc. Once you put the key press enter and you will get a table with everything you stored inside the data key. You can edit or add or remove something from it. Then you can save(every 10 seconds so you dont overload the data). Thanks.
Datastore Link: Datastore2 Editor - Roblox

1 Like

How would I appropriately use SaveAsync() and determine if data sucessfully saved? This is my current snippet of sample code:

InventoryStore:Set(Inv)
local success, errorMessage = pcall(function()
	InventoryStore:SaveAsync()
end)
	if not success then
		print(errorMessage)
	end

Many people have started getting errors with DataStore2. We don’t know if it is Roblox issue or DataStore2 issue, but it is definitely not an issue on our side.

The error:
HTTP Unknown Error (TlsVerificationFailed)

This happens whenever player quits the game. The game freezes for 20-30 seconds and this error comes out.

That is definitely not a DataStore2 issue.

That looks right to me, though be cautious about how much you save.

I’ll put bug report topic here.

And announcement too.

For the past 2 months, I’ve been trying to resolve an issue in my game where DataStore2 causes Studio to return the error Script with BindToClose callback was destroyed; callback cannot be called!
This is causing the data not to save. Any ideas as to how to fix this or what is causing this?

Are you using the latest version from GitHub?

Also, where is your DataStore2? A script should never be destroyed unless you are dong something weird, like putting it inside a tool or something.

Yes, I am using the latest version
DataStore2 is inside ServerScriptService

Edit: In case it wasn’t clear, DataStore2 has been on the correct version and in ServerScriptService even before this issue began

First of all, sorry if this has been asked a thousand times.
I can’t seem to find a answer for my problem, at least one I understand…

In my game, the player is able to create custom data.
Which is:
image_2022-06-23_190255105

The player created the folder name, and the values.
So in theory there can be 100 folders, each having those 3 StringValues, which have unique player chosen values.

My question is, how do I save the entire “Videos” folder.
I’m still trying to figure out DataStore2, so I’m sorry if this is obvious.

Sorry for bothering.

You’ll need to map it with your code into inputs for the datastore.

I don’t understand this question

I am immature in speaking English.
I want to know how to save at any time

The tutorial linked in the first post is a really good way to jump into this.

1 Like

DataStore2 is being used in two places in the same experience, would that be part of the issue? I do not see why it would, but I don’t have any better guesses.

Edit: I got it figured out. If anyone else has this issue, just read through issue #135 on the GitHub repository

I’m somehow getting this error? pls help
image
image

1 Like

How well is datastore2 able to handle a value that changes quickly over a period of time, that may need to save? I am making a sort of resource managing game, and the resources may change quickly. I want these resources to save.

Hi there, my game has been using DataStore2 for a while now but we implemented a “quests” feature which saves a table and has worked for a while. On release, players were being given random default values their first time in the game which showed them having made very odd progress on quests. Any ideas how we could be calling the wrong data?


local DataStoreService = game:GetService("DataStoreService")
local datastore =  DataStoreService:GetDataStore("Coins")

I have found a major issue with the latest version of DataStore2.

When loading multiple DataStores with multiple players, it takes a while for everything to load.

image
Here is a screenshot from a YouTube video with 6 players inside.

I have a Dev Build of the next update for my game that uses ProfileService and the issues that DataStore2 have are nonexistent…

Here is an example of what the DataStore2 scripts looked like:

local DataStore2 = require(game:GetService("ServerScriptService").DataStore2)
local CombinedDataStore = DataStore2.Combine("PlayerData", "PlayerDataBackup")

local DefaultTable = {
	["MultiplayerWins"] = 0,
	["BattleWins"] = 0,
	["IsWinObby"] = false,
	["IsLikedGame"] = false,
	["VersionPlayed"] = "4.0"
}

game:GetService("Players").PlayerAdded:Connect(function(Player)
	local DataStore = DataStore2("PlayerData", Player)

	local DataTable = DataStore:GetTable(DefaultTable)

	local Data = Instance.new("BinaryStringValue")
	Data.Name = "PlayerData"
	Data.Parent = Player

	for DataType, Value in pairs(DataTable) do
		Data:SetAttribute(DataType, Value)
	end

	for DataType, Value in pairs(DefaultTable) do
		if not Data:GetAttribute(DataType) then
			Data:SetAttribute(DataType, Value)
		end
	end

	Data.AttributeChanged:Connect(function()
		local DataToSave = {}

		for Map, Value in pairs(Data:GetAttributes()) do
			DataToSave[Map] = Value
		end
		DataStore:Set(DataToSave)
	end)
end)

I expect 8 to run at the same time when a player joins. It loads instantly just fine with 1 player, but when 2 or 3 join, data takes a long time to load.

I would love to work with you to fix this major DataStore2 issue, I will give you all the info that you need to fix the issue.