So I have a few places within my game the main game has my datastore script and I’ve been trying to figure out how I can access a players data from one of the places I’m pretty sure I did this before, but forgot how so my current solution was to just copy and paste the script from the main game and I’m pretty sure this isn’t the right way to do it because I feel like it would just be a pain to have to update both of the scripts so yeah need some help with this.
Use the same name, scope and key, the roblox datastorage works by universe and share the data with those places.
Ok so I don’t need to copy and paste my whole script? As long as I get the datastore and use the same name it will work?
Yes, same data storage and same key.
so in my datastore script I have this
local DSVersion = 3
DataStore = Main.DSS:GetDataStore("LiveDataStore"..DSVersion)
and then in the second place I just did this
local DataStore = Main.DSS:GetDataStore("LiveDataStore3")
local PlayerUserId = "Player_" .. Player1.UserId
local Success, Data = pcall(function()
return DataStore:GetAsync(PlayerUserId)
end)
if Success then
if Data then
for i,v in pairs(Data) do
warn(i,v)
end
warn("Selected Stage: "..Data["PreferredStage"])
else
warn("No data")
end
end
But it keeps saying no data I’m guessing I did this wrong? lol
I think you should put it like this:
DataStore = Main.DSS:GetDataStore("LiveDataStore".. tostring(DSVersion)
nah it’s fine like that lol also that’s not the issue anyways or at least I dont think it is? The code in the top part is from the datastore script in the main game which works fine
Edit: You know what problem solved I had a typo the entire time LOL god programming kind of be a pain sometimes
so it works fine with the normal datastore ?
i mean there is something called global data store i still do not what is the different between these two but i read that you can only get data from other places in the same universe using the global data store