Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What's the DataStore key corresponding to a DataStore2 combined key?

How would one find this out? There is no documentation out there for this that I could find.

For example, function setup runs whenever a player joins my game:

local DataStore2 = require(1936396537) --ds2
DataStore2.Combine("Main", "Data")

local function setup(player)
	local data = DataStore2("Data", player)
	
	data:Update(function()
		return 100
	end)
end

The Master Key is Main and the Key I want to access through Roblox's DataStore is Data.

I need this because I'm using DataStore2 in a game and need to access an offline player's data.

I found a thread and tried the answer, but wasn't lucky. I tried many things, such as the following:

--158259 is my uid
local ds = game:GetService("DataStoreService"):GetDataStore("Main/158259")
local d = ds:GetAsync("Data/158259") --nil
local ds = game:GetService("DataStoreService"):GetDataStore("Main")
local d = ds:GetAsync("Data/158259") --nil
local ds = game:GetService("DataStoreService"):GetDataStore("Main/Data")
local d = ds:GetAsync(158259) --nil, datatype string is still nil as well

And many others to no avail.

Help would be appreciated.

1 comment

0

one second

1 answer

For DataStore2, you need to get data by using this

local PLAYER_ID = 100000 -- change this to the player id you want
local STORE_NAME = "Data" -- change this to the DataStore's key, the string which you use in DataStore2(player, string)
local VERSION_GET = "0" -- put the version number you would like to get.
local DataStore = game:GetService("DataStoreService"):GetDataStore(STORE_Name.."/"..PLAYER_ID)
print("Data found!" .. DataStore:GetAsync(VERSION_GET))

Hope this works!

2 comments

0

Will not work, I am positive

0

Not sure where you got this idea but I'm pretty sure I need a reference to the master key somewhere at least. Thanks for the response but yea this does not work.

This discussion is preserved as it was. New answers, comments, and votes are closed.