Using Data Stores Across Linked Games

Is there a way to transfer data with data stores or any other method between games? The two games I’m attempting this with a parent and child, so one game is located inside the other.
image

3 Likes

Is your place under the same universe?
DataStores work per universe, so as long as they are the same universe it will transfer

1 Like

I think so. It’s this:

The Valley
|_Place Number 27.

Is that considered a universe?

1 Like

Yes, Place Number 27 and The Valley are under the same universe

Think so, I think you could use the same GlobalDataStore (same name) in both games.

Okay, so I can just call a data store from the other game if needed?

As long as they are under the same universe (which they are), yes

I’ve tried prototyping a script, but the script isn’t getting any of the data on the other game

Main Game:

local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local TestStore = DataStoreService:GetDataStore("TestStore")

game.Players.PlayerRemoving:Connect(function(Player)
	local BlockInfo = {
		P = workspace,
		N = "TestingBlock"
	}
	TestStore:SetAsync("BlockData",BlockInfo)
	
end)

Secondary Game:

local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local TestStore = DataStoreService:GetDataStore("TestStore")
game.Players.PlayerAdded:Connect(function()
	local Data = TestStore:GetAsync("BlockData")
	print(Data)
	local Block = Instance.new("Part")
	Block.Parent = Data.P
	Block.Name = Data.N
	Block.Position = Vector3.new(-232, 120, -140)
	print(Block.Name)
end)

Is Studio Access to API Services enabled in Game Settings > Security?

Yes, it’s active in both of the games

You’re not gonna be able to send workspace so this will be nil but I don’t know if this is causing the problem. Try pcalling the SetAsync

local success, errorMessage = pcall(function()
TestStore:SetAsync("BlockData",BlockInfo)
end)

if success then
print("Data saved successfully")
else
print(errorMessage)
end

It came back with an error saying this:
104: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters.

Oh yeah, you can’t store dictionaries in datastores.

1 Like

Should I instead encode it into a JSON then decode it in the other game?

Yeah, that’s one way of doing it.

I’ll try that out. Thanks for the help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.