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)
Since the points value was not changed/updated, DataStore2 did not save the value.
Edit: Sorry for bumping.
Hey,
is there a Community Ressource for DataStore 2 on Discord or on any other Social Media? If so can you send me the link so I can discuss with someone because I have a lot of question for that
Hey so how do i get the current value of the datastore? Do i just do something like:
local stat = game.Players.bbackstab.leaderstats.Stat.Value
Hey!
I’m not entirely sure if I wrote this correctly: but I’m having the same warning every time I run the game.
I’m trying to save a table of keybinds that each Player can change, so that it will stay the same the next time they join.
Here is the code:
-- VARS ||
local Players = game:GetService("Players")
local Datastore2 = require(script.Parent.DataStore2)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Data_Sync = ReplicatedStorage.Remotes.DataSync
-- ||
local defaultkeybinds = {
Interact = Enum.KeyCode.E,
Console_Interact = Enum.KeyCode.ButtonX,
SecondaryInteract = Enum.KeyCode.F,
Console_SecondaryInteract = Enum.KeyCode.ButtonY,
CloseMenu = Enum.KeyCode.X,
Console_CloseMenu = Enum.KeyCode.ButtonB
}
Players.PlayerAdded:Connect(function(PLAYER)
local keybindDataStore = Datastore2("KEYBINDS", PLAYER)
local keybinds = keybindDataStore:Get(defaultkeybinds)
Data_Sync:FireClient(PLAYER, keybinds)
end)
Data_Sync.OnServerEvent:Connect(function(PLAYER, TABLE)
local keybindDataStore = Datastore2("KEYBINDS", PLAYER)
keybindDataStore:Combine("DATA", "KEYBINDS")
keybindDataStore:Set(TABLE)
end)
I’m specifically having trouble on the last function, it keeps throwing a: error when player left! Invalid at input.Interact because: Invalid type (EnumItem)
error whenever I leave the game.
Anyone know the issue and can help me troubleshoot?