please tell me how to transfer the database to another game, I tried using http code to transfer all the keys from the database, but I ran into problems writing that Instance
local DataStoreService = game:GetService("DataStoreService")
local LiveStats7 = DataStoreService:GetDataStore("LiveStats7")
local function printFirstKey()
local success, iterator = pcall(function()
return LiveStats7:ListKeysAsync()
end)
if success and iterator then
local page = iterator:GetCurrentPage()
if #page > 0 then
local firstKey = page[1].Key
print("key: " .. firstKey)
else
print("naah.")
end
else
warn("nah.")
end
end
printFirstKey()
Error:
19:24:39.063 Key is not a valid member of DataStoreKey “Instance” - Edit
you cant transfer all players progress from project a to project b unless you use an external database
you can use print for debugging like this
print(page)
20:15:02.697 ▼ {
[1] = Instance,
[2] = Instance,
[3] = Instance,
[4] = Instance,
[5] = Instance,
[6] = Instance,
[7] = Instance,
[8] = Instance,
[9] = Instance,
[10] = Instance,
[11] = Instance,
[12] = Instance,
[13] = Instance,
[14] = Instance,
[15] = Instance,
[16] = Instance,
[17] = Instance,
[18] = Instance,
[19] = Instance,
[20] = Instance,
[21] = Instance,
[22] = Instance,
[23] = Instance,
[24] = Instance,
[25] = Instance,
[26] = Instance,
[27] = Instance,
[28] = Instance,
[29] = Instance,
[30] = Instance,
[31] = Instance,
[32] = Instance,
[33] = Instance,
[34] = Instance,
[35] = Instance,
[36] = Instance,
[37] = Instance,
[38] = Instance,
[39] = Instance,
[40] = Instance,
[41] = Instance,
[42] = Instance,
[43] = Instance,
[44] = Instance,
[45] = Instance,
[46] = Instance,
[47] = Instance,
[48] = Instance,
[49] = Instance,
[50] = Instance
} - Edit
what happen?
if I use the plugin to find out the keys, then it writes normally, but here it is
Use API keys, and make a system that when a player joins your new game, your API checks if that player already has data on the old game and writes that old game’s data to the new game.
can you help me create an API?
You’ll need a proxy, as HTTP service doesn’t allow requests to Roblox resources.
If you make an API key under the old game and give it universe.data-stores:read
permissions, you can send a GET request to the endpoint https://apis.roblox.com/cloud/v2/universes/OLD_UNIVERSE_ID/data-stores/DATA_STORE_NAME/entries/key
(no scope included; it doesn’t look like you used a scope) in order to get the data.
--this code is untested, and it might not work as I haven't used this API with HttpService before
local httpService = game:GetService("HttpService")
local apiKey = --api key, I would recommend using a secret and then HTTPService:GetSecret()
local function getData(player: Player)
--you might want to retry multiple times, but I'll only show one here
local success, response = pcall(httpService.RequestAsync, httpService, {
--remember to use a proxy for the url, and to define the interpolated variables!
["Url"] = `https://apis.roblox.com/cloud/v2/universes/{old_universe_id}/data-stores/{data_store_name}/entries/{player.UserId}`, --remember to add key prefixes/suffixes
["Headers"] = {["x-api-key"] = apiKey},
["Method"] = "GET"
})
if (success) then response = httpService:JSONDecode(response) end
if (not success or response.StatusCode ~= 200) then --failed
--etc...
end
return response.value --the data
end