I have four games (they are all linked to the start place meaning they are not a whole other place) that use the same data for saving leaderstats. I have set up the datastore so it saves when the player leaves and when they press a button. For some reason it only saves data on the start place. The script it is located in ServerScriptService on all the places. It is a server script and I have datastore enabled on all games. It also is enabled to save in studio for all games.
Here is my code:
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("Coinssssss")
local function SetUpnLoad(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Coin = Instance.new("IntValue")
Coin.Name = "Coin"
Coin.Parent = leaderstats
-- Datastore stuff
local key = "player-"..player.UserId
local Saved
local success, message = pcall(function()
Saved = DataStore:GetAsync(key)
end)
if not success then
warn("Failed to read Data"..tostring(message))
return
end
if Saved then
Coin.Value = Saved[1]
else
Coin.Value = 500
local Values = {
Coin.Value
}
local complete, err = pcall(function()
DataStore:SetAsync(key, Values)
end)
if not complete then
warn("Failed to over-right data"..tostring(err))
return
end
end
end
local function Save(player)
local key = "player-"..player.UserId
local Values = {
player.leaderstats.Coin.Value
}
local success, err = pcall(function()
DataStore:SetAsync(key, Values)
end)
if not success then
warn("Failed to over-right data"..tostring(err))
return
end
return Values
end
local function SaveGame(player)
local key = "player-"..player.UserId
local Values = {
player.leaderstats.Coin.Value
}
local success, err = pcall(function()
DataStore:SetAsync(key, Values)
end)
if not success then
warn("Failed to over-right data"..tostring(err))
return
end
game.ReplicatedStorage.Events.FinishedSave:FireClient(player)
return Values
end
game.ReplicatedStorage.Events.SaveGame.OnServerEvent:Connect(SaveGame)
--Fired when the player click a button
game.Players.PlayerAdded:Connect(SetUpnLoad)
game.Players.PlayerRemoving:Connect(Save)
I don't know why this is not working so any help is appreciated! Thanks!

10 comments
I use datastores a lot but this is my first time using multiple places
DataStores are per place. If you need it for a whole different universe you may want to make a different game in the place and not a whole different place.
Yes ^ what incap said....
Lets hope that the script is copied with a datstore of "Coinssssss"
That would just make a new data store all for that place.
Then how do games like meep city do it? They have a racing game where you can earn money (can't remember what the currency is really called). It saves between games
by the way I did copy the script so yes they all have the same datastore
Oh and I do have the start place have games inside of the place. They are all linked in one game
Because MeepCity racing is a game in the MeepCity place, they share the universe
Thanks I just figured it out on my own.