Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Accessing DataStore from another game?

Asked by 8 years ago

Hello. Is there a method to access DataStore from another game? I want to create place and read data from another place DataStore.

2 answers

Log in to vote
1
Answered by 8 years ago

You can't

DataStores don't work across universes, so if you need to store data for two places you're better off either putting them in a Universe together, or using HttpService with a web service such as Trello.

Ad
Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

Simply use the same DataStore you used in the first, and read from it just as you would normally.

In one game:

DS = game:GetService("DataStoreService"):GetDataStore("DataStoreName")
local key = "player_" ..player.userId
DS:SetAsync(key, "Test")

In another:

DS = game:GetService("DataStoreService"):GetDataStore("DataStoreName") -- Make sure it's the same name!
local key = "player_" ..player.userId
local test = DS:GetAsync(key)
print(test)

Should print Test. Hope this helped.

0
Games is not in same universes NAUSHNIK52 0 — 8y
0
As SatireIncarnate said, it'd be easier on you to just put them in the same universe. Pyrondon 2089 — 8y

Answer this question