I’m very new to datastores, so I was wondering; how is :GetAsync()
only called once, being that it’s only called the first time you use the module?
Roblox has openly mentioned DataStore2 being an outdated method of saving on Roblox. Developers liked this method previously because it supported data versioning. New updates to data store API have added versioning and more great changes. Data Stores | Documentation - Roblox Creator Hub
I believe you are referring to the OrderedBackups type of store.
Not sure what an OrderedBackups type of store is. But the structure behind DataStore2 involves using ordered datastore to maintain the most recent save version and the key related to the save to avoid data overwriting.
This is considered legacy and is explicitly recommended against in the DataStore2 documentation.
It is no longer recommended. Please use the standard data store type instead, which does not provide the legacy versioning features.
I thought I saw a post regarding it earlier in this thread, but sadly I could not locate it.
how do I use .combine with multiple scripts? Do I run the combine code in every single script or make a server script just for combining and should the data scripts wait for it to combine?
Hey! I’ve only just been starting to use this. I’ve ran into an issue though.
Using the DataStore2 Module, I added new lines right below the SaveInStudio check in the SaveAsync() function.
I want to make it so that DataStore2 does not save if a certain bool value is on. For some weird reason it only detects what the bool’s value is when the server starts. Changing the bool mid-game and then leaving still makes it save data. Is there a way to fix this?
Here’s the code if it’s needed:
local DataDisabledObject = ServerStorage:FindFirstChild("AbleToSaveData")
local DataDisabled = DataDisabledObject and DataDisabledObject.Value
if not DataDisabled then
warn(("Data store %s attempted to save, however AbleToSaveData was disabled."):format(self.Name))
if not DataDisabledObject then
warn("Data Disabler isn't in ServerStorage. Data functionality can possibly be bad.")
end
resolve(false)
return
end
While I may not consider myself an expert in scripting, I found DataStore2 to be significantly more straightforward than utilizing profileservice. Moreover, the setup process was remarkably simple for me. This is just my opinion but profileservice is way too complicated for most people like me that are just starting to script so for anyone looking for an alternative this is a great choice!
Random rejection
- It does save in-game but sometimes it rejects, which results in non-saving data
Datastore2 seems not maintained anymore, i’m currently too busy to switch to ProfileService
Does anyone know a fix for this error? (DataStore2
> SavingMethods
> OrderedBackups
)
Edit:
Edited the Standard saving method to retry whenever 403 (Forbidden)
occurs
self.dataStore:UpdateAsync(self.userId, function()
return value
end)
Updated Code
Make sure to use the latest Promise release if you use this edit
-- Standard saving of data stores
-- The key you provide to DataStore2 is the name of the store with GetDataStore
-- GetAsync/UpdateAsync are then called based on the user ID
local DataStoreServiceRetriever = require(script.Parent.Parent.DataStoreServiceRetriever)
local Promise = require(script.Parent.Parent.Promise)
local Standard = {}
Standard.__index = Standard
function Standard:Get()
return Promise.async(function(resolve)
resolve(self.dataStore:GetAsync(self.userId))
end)
end
local function updateAsyncRequest(self, value)
return Promise.new(function(resolve, reject)
local success, result = pcall(function()
self.dataStore:UpdateAsync(self.userId, function()
return value
end)
end)
if (success) then return resolve(result) end
reject(false)
end)
end
function Standard:Set(value)
return Promise.retryWithDelay(updateAsyncRequest, 5, 1, self, value)
end
function Standard.new(dataStore2)
return setmetatable({
dataStore = DataStoreServiceRetriever.Get():GetDataStore(dataStore2.Name),
userId = dataStore2.UserId,
}, Standard)
end
return Standard
You can literally watch a tutorial on ProfileService that explains it great. One such tutorial is from VectorThree.
i have but i dont use it because i dont understand it even after watching tutorials plus i’d rather make it myself so if i want to add anything i can know where to start
This just looks like a Roblox outage to me.
Yes I know. I wasn’t specific enough. I meant like, isn’t there a way to prevent this from happening, as in retrying to call the function?
I wouldn’t recommend it. Just use the DataStore from Roblox. What I do is I create a module script where, if a player joins, their data will be stored in a table. If they don’t have existing data, new data will be created. I store everything in this table, and when the player leaves, it gets saved.
Suphi’s Datastore Module is the best option rn imo.
Well, it has its downsides. I’d still prefer to use ProfileService over Suphi’s Datastore Module.
Thank you so much for creating this, I’m gonna use it for my little game named normal day.
I hope there won’t be any data losess like they happened (4 times they happened and they were pretty big)
if anyone interested what the data losses was so here u go: first and second data loss was the serial keys they were lost 2 times (idk why to this day) the third data loss was the players money and the fourth data loss was companies budget (basically 170k money reset thats alot tho i backed it up to somewhat around this value)
These two already explain by DataStore2 should not really be used anymore. You should either use the default Roblox Datastores with their new API and all that stuff or you can use ProfileService which I have given a link to a great video explaining how to use it above.
Edit: Roblox Datastores do provide versioning! (ProfileService does too)