Excellent! This might just be the storing mechanism in my next game!
So I keep getting the error "Cannot save data as it was previously session locked.
This happens when I put the data in a module table in order to have multiple scripts have access to it.
local DEFAULT_DATA_TEMPLATE = {
Strength = 0
}
--Variables
local Players = game.Players
local ServerStorage = game.ServerStorage
local PublicDataStorage = require(ServerStorage.PublicDataStorage)
local QuickNetwork = require(ServerStorage.QuickNetwork)
local DataNetwork = QuickNetwork.GetDataNetwork("DataNetwork", DEFAULT_DATA_TEMPLATE)
--Handle Data Corruption
DataNetwork.DataCorruptionSignal:Connect(function(key, errormessage)
return "LoadBackup"
end)
--Functions
local function PlayerAdded(player)
local data = DataNetwork:LoadDataAsync(player.UserId)
--Fill missing variables
data:Reconcile()
PublicDataStorage.Data[player.UserId] = data
end
local function PlayerLeave(player)
local data = PublicDataStorage.Data[player.UserId]
if data then
data:Clear()
end
end
--Connections
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(PlayerLeave)
for _, player in ipairs(Players:GetPlayers()) do
coroutine.wrap(PlayerAdded)(player)
end
EDIT: I turned on BindToShutdown and SaveOnShutdownInStudio
Players.PlayerAdded:Connect(PlayerAdded)
for _, player in ipairs(Players:GetPlayers()) do
coroutine.wrap(PlayerAdded)(player)
end
Players.PlayerRemoving:Connect(PlayerLeave)
I think this might be the problem.
That did not fix it but thanks anyways
[5/4/2021]: QuickNetwork Update [v1.70]
QuickNetwork now comes with its own updated script which updates the module automatically every 3 seconds, make sure to place that script in ServerScriptService.
-
Fixed the while loop condition where data loaded wouldn’t be auto saved.
-
Fixed a bug where data would error after
Data:Clear
was completed. -
Other small edge case bug fixes.
-
Data:Reconcile
now supports nested table, same withData:SetTable
. -
Data:CombineDataStoresAsync
andData:CombineKeysAsync
now will only update the data if new keys were added. -
Data auto saved now outputs that the data was auto saved, not “saved”. This is just for better logging purposes.
-
New method,
DataNetwork:GetCachedData(key)
, which returns the cached data. -
Removed unnecessary methods like
DataNetwork:Destroy
.
Update your module here:
I updated QuickNetwork yesterday, and it contained many bug fixes. So first, make sure you update the module. The error that you’re seeing comes when you try to save data that was session locked, this is nothing really to worry about.
I experienced none of my data saving. I didn’t change anything in the Script either. The only thing different was I updated the Module.
I’m having the exact same problem. I downloaded the module (version 1.70), installed it how the documentation instructed so, and copy and pasted the example code into a script and ran it in-game. I waited about a minute to rejoin the game, and the cash amount always returned 15 cash. I’m actively looking for where the problem can arise, to no avail. I’ll update you guys if I find a solution.
EDIT: I did notice that it still states it is auto-saving, but throwing “attempt to index nil with BoundToClear” on Utility, Line 85.
Yes, I downloaded after the 1.70 quick update. And I am testing this in-game, since I’m very weary of saving live data in Studio.
What errors are you getting? Can you show the output? I’m seeing no problems on my end, nor any errors.
Most likely you messed up the source:
These were the errors being thrown. Also, that could be true, cause my actual game data never threw these errors, but I was still having saving issues with those too.
EDIT: So the issue was I installed it into ServerScriptService instead of ServerStorage… whoops!
[10/4/2021]: QuickNetwork Update [v1.8]
Improvements:
-
QuickNetwork
now will output even very verbose warning messages and errors and will error check more. -
QuickNetwork
has now been refactored, all memory leak fixes, code standardization and code readability have been majorly improved! -
Documentation has been updated to reflect all the changes.
-
QuickNetwork
will now reduce the keys inMetaData
of any data except for necessary ones, which means that the session lock fordata
has been completely reworked.
Changes
-
QuickNetwork
will now by default, save data on shutdown. -
DataCorruptionSignal
has been renamed toDataCorruptionLoadSignal
.
New edge cases which are handled:
-
QuickNetwork
will now not save data unnecessarily uponUpdateAsync
call if it was session locked. -
QuickNetwork
will now wait for the data to be cleared during server shutdown (if it is) instead of clearing it again. -
Data:CombineDataStoresAsync and Data:CombineKeysAsync will now not combine data stores or keys unnecessarily if they were previously combined. These methods will now ONLY update the data accordingly.
-
No more small freezes when
QuickNetwork
saves data on server shutdown.
QuickNetwork (v1.8) is now officially out of beta, which means its stable and you should expect no bugs!
Update your module here:
Hello, thank you for making this Data Store. Due to the crazy amount of lag that was created once updating a larger table using DataStore2, I decided to try out something new (In this case QuickNetwork). It seems to work really well, however it is a bit of a bummer that the documentation is down. A quick note is that this happens every time the game is started from Roblox Studio:
ServerStorage.Modules.DataStore.QuickNetwork:187: attempt to index nil with 'MetaData'
The functions are a bit tricky to figure out without documentation so I had to modify the “Set” function in order to make it update my tables. (SetTable doesn’t update my table given a key and a table as value)
Ah that is a big rip since I just ported my game to use this lol. Is there no way to get the “actual” data store module which you mentioned?
Sorry for bumping. But this is simply an masterpiece. Great Alternative. Gets the job done. Etc.
The documentation link and GitHub link both lead to 404s. Looking forward to giving this a try once this is fixed!
Can I petition for a rename? QuickNetwork sounds like a name for a Networking package for remote events/functions. Maybe QuickStore or QuickSave might be a more intuitive name.?
Sorry for bumping; opening the documentation and Github Source page led to 404s.
Sorry for bumping too, but yeah github source page still isn’t up after a year