How to add datastores from a different place?

Hey Everyone,
So for my story game, I’m adding wins from a different place that’s in the same game. I’ve heard this is possible but I’m not sure how to achieve it.
Here is the script I have in the lobby:

local Players = game:GetService('Players')
local DataStoreService = game:GetService('DataStoreService')

local WinsDataStore = DataStoreService:GetDataStore('Wins')


Players.PlayerAdded:Connect(function(Player)
	
	local Stats = Instance.new('Folder')
	Stats.Name = 'leaderstats'
	Stats.Parent = Player
	
	local Wins = Instance.new('IntValue')
	Wins.Name = 'Wins'
	Wins.Parent = Stats
	
	
	local Data = WinsDataStore:GetAsync(Player.UserId)
	
	
	if Data then
		for name, value in pairs(Data.Stats) do
			Stats[name].Value = value
		end
		
	end
	
		
		
end)

Players.PlayerRemoving:Connect(function(Player)
	local SaveData = {Stats = {}}
	

	
	for _, stat in pairs(Player.leaderstats:GetChildren()) do
		SaveData.Stats[stat.Name] = stat.Value
	end
	

	
	
	
	WinsDataStore:SetAsync(Player.UserId,SaveData)
	
	
end)

game:BindToClose(function()
	for _, Player in pairs(game.Players:GetPlayers()) do
		local SaveData = {Stats = {}}
		

		
		for _,stat in pairs(Player.leaderstats:GetChildren()) do
			SaveData.Stats[stat.Name] = stat.Value
		end
		

		
		WinsDataStore:SetAsync(Player.UserId,SaveData)
		
	end
	
	wait(2)
end)

How can i add 1 win in a different place? I have no datastores in the other place.

1 Like

I’m not very good at the DataStore, but I can give advice on how this can be implemented. I met games that check badges or gamepasses from a player from another place. I would advise to make Badge with 1 victory in first Place . And through the code in another game, check for the presence of this badge of the player.

1 Like

Yes, but you can only award badges once. and Every time they win, I need to add a win…

1 Like

datastores should transfer, just try using the same script and see if it works.

1 Like

So I should just add the same script in the new place? Or modify it?

1 Like

Just try adding it, it should work as long as nothing is different.

2 Likes