I have a datastore that works perfectly fine in one game, but when i put it into another, it does not work. i have literally copy and pasted the same thing into each game, and both games have API services turned on. the code is below.
local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService:GetDataStore("StarterCarUpgrades")
game.Players.PlayerAdded:Connect(function(Player) local clone = game.ReplicatedStorage.PlayerData:Clone() clone.StartercarUpgradeValue.Value = DataStore:GetAsync(Player.UserId) or 0 clone.Name = "PlayerData" clone.Parent = Player end)
game.Players.PlayerRemoving:Connect(function(Player) DataStore:SetAsync(Player.UserId, Player:WaitForChild("PlayerData").StartercarUpgradeValue.Value) end)
It's because each game has their own data saved. For example, you have a pet saved in Adopt Me. Would you expect your data would also show up in Murder Mystery 2? No! Just because you used the same DataStore name in a different game, doesn't mean it would have the same data from the other game.
If you try to transfer a DataStore script to an another game, it will just start a new copy of the DataStore from the previous game except it is reset back to no data saved.
There is no fix to this, except that you can use Badges to detect when a player owns something in the game. You can use that when you try to share your data to another game (probably your other game) like what The Mimic will do to their new game Yokai.
But you can only use Badges if you want to check if the player has earned an item or completed a quest, not for checking numbers and leaderstats.