So this hasn’t been talked in a while, after all research I did I couldn’t find anything to accomplish my issue with transferring a datastore (player savings) from an experience to another experience. Not a place related to a same experience universe, but 2 separated games.
If anyone has a solution or an answer for this it would be great, well I’m not trying to link 2 datastores together, Just to copy the data saved from the other
You could possibly create a script that goes through all the keys, adds them to a table and then JSON encode it and do it in reverse on the target game
Technically you need to achieve the following 4 steps:
Fetch all the data from the original game
Save it somewhere locally just in case you don’t lose it and you have to repeat step 1(you can print the data and copy-paste it into a file if it’s large then find ways to compress it or split it into multiple strings, JSON sounds like the easier option here)
Do some coding magic(conversions of how data is saved error handling etc)
Save all the data to the target game
The hard steps are the first and last one because as far I’m aware Roblox doesn’t have the option to bulk download or write to a datastore, meaning that as the data grows this process will become MUCH slower because you will be forced to fetch and save keys one by one.
So according to that, you have 2 options:
If the original game doesn’t have many keys just loop through all of them and save them to the new datastore, make sure to have a way of detecting failures and saving them so you can do the process over and over again until all the data is transferred.
If the game has large amounts of data, let’s say millions of users instead of moving all the data, move only the important data, for example, add an option for the new players of the target game to go to the old one to start the data fetch process for that specific key and only automate the process of data recovery of visible accounts, let’s say for example accounts that impact leaderboards and what the end user sees.
My reply is highly theoretical in the sense that it doesn’t provide much information about how to achieve most of the steps mentioned, and that’s mainly because every game has a different way of storing player data and handling it, meaning that you have to adapt your solution based on the data management of the original and target game. I also personally think Roblox as a platform should give devs the ability to bulk download/save/delete player datastore keys as this will save most games from large amounts of API calls they already do(for example a game could mass delete the data of GDPR requests once per week/month instead of doing it per key).
PS: Also another issue that may arise is that you may be unable to find the player keys unless you store the information of every player that joins(for example id) somewhere. If you haven’t stored it anywhere you can do some API magic and fetch all the users that own your game’s welcome badge. If that’s also not true, then you are in for a wild ride I’m afraid.
PS 2: I take PS 1 back, you can fetch datastore keys using DataStore:ListKeysAsync, but it’s done in a page-like way meaning you will have to write code for looping through the pages and such.
Well here’s something I quickly wrote up (using some documentation code) (it’ll be slow):
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("DataStore") -- Change this for your datastore name
local function pagesToTable(pages)
local items = {}
local pageIndex = 1
while true do
for i,v in pairs(pages:GetCurrentPage()) do
local name = v.KeyName
items[name] = DS:GetAsync(name)
end
print("Added page", pageIndex)
pageIndex += 1
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
end
return items
end
print(game:GetService("HttpService"):JSONEncode(pagesToTable(DS:ListKeysAsync()))) -- Would probably advice against printing it if it's a large datastore since you'll probably crash your computer trying to display it in the console so maybe find an API to post it to idk
If you have a list of data you can do it like this (might be faster):
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("DataStore") -- Change this for your datastore name
local keys = DS:GetAsync("keys") -- Must be an array
local data = {}
for i,v in pairs(keys) do
data[v] = DS:GetAsync(v)
end
print(game:GetService("HttpService"):JSONEncode(data)) -- Again I don't advice
As for importing:
local http = game:GetService("HttpService")
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("DataStore") -- Change this, too
local json = "Paste JSON here or pull it from somewhere like pastebin"
local data = http:JSONDecode(json)
for key, value in pairs(data) do
DS:SetAsync(key, value)
end
It won’t be fast, but it’s the only real option that I know of
You could send a teleport string then update the other data stored once they teleport there. But, there is a limit to the length of the string passed and you would need to format it so you could then add it the other store. Other than that you could use an outside data storage they both can link to, to pass the data.