GlobalDataStore

I tell you that my doubt is the operation of the globaldatastore, I need to save values within the 2 games that I am doing so that the player has his inventory saved in the games. the games are in the same place.
This is the script I use to save the data right now and I created another extension that should reproduce the value in the other place but it doesn’t work. I would like someone to teach me the reason why it does not work. Thank you.

local DataStore = game:GetService("DataStoreService")
local Data1 = DataStore:GetDataStore("Data1")

game.Players.PlayerAdded:Connect(function(player)
	--test
	local Test = Instance.new("Folder", player)
	Test.Name = "Test"
	
	local Test1 = Instance.new("IntValue", Test)
	Test1.Name = "Test1"
	
	local DataA1
	
	local ok, errorf = pcall(function()
		DataA1 = Data1:GetAsync(player.UserId)
		
	end)
	if ok then
		print("Data")
		Test1.Value = DataA1 or 0
	else
		print("Error")
		error(errorf)
	end
	while true do
		wait(10)
		player.Test.Test1.Value += 1
	end
	
	
end)
game.Players.PlayerRemoving:Connect(function(player)
	local ok, errorf = pcall(function()
		Data1:SetAsync(player.UserId, player.Test.Test1.Value)
	end)
	if ok then
		print("DataB")
	else
		print("ErrorB")
		error(errorf)
	end
end)
local ds = game:GetService("DataStoreService"):GetGlobalDataStore()
game.Players.PlayerAdded:Connect(function(plr)
	wait()
	local plrKey = "id_"..plr.UserId
	local save1 = plr.Test.Test1
	
	local Saved = ds:GetAsync(plrKey)
	if Saved then
		save1.Value = Saved[1]
	else
		local NumberForSaving = {save1.Value}
		ds:GetAsync(plrKey, NumberForSaving)
		
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	ds:SetAsync("id_"..plr.UserId, {plr.Test.Test1.Value})
end)

if your scripts are in the same game but under different places you can just replace the top line of your second script with:

local ds = game:GetService("DataStoreService"):GetDataStore("Data1")

the reason your second script is not reproducing the data in the first is because they are two completely separate datastores

the 2 scripts are separate and in the 2 games. then I have to join them because embes of saving the information creates another base generating error?

embes

??

As Jack said, just have them use the same DATASTORE and same KEY, and the data should go between them fine