This only loads some of the cash that the player had
local DataStoreService = game:GetService("DataStoreService") local Money = DataStoreService:GetDataStore("Money") -- game.Players.PlayerAdded:connect(function(plr) local key = "user_"..plr.userId local stats = Instance.new("IntValue",plr) stats.Name = "leaderstats" local level = Instance.new("StringValue",stats) level.Name = "Mode" level.Value = "Choosing" local money = Instance.new("IntValue",stats) money.Name = "Cash" money.Value = Money:GetAsync(key) or 0 money.Changed:connect(function() Money:SetAsync(key, money.Value) end) end)
Try using UpdateAsync, and making a function to determine whether or not an old key was saved. Like this:
local DataStoreService = game:GetService'DataStoreService' local Money = DataStoreService:GetDataStore'Money' local Players = game:GetService'Players' local DefaultMoney = 1 -- what they start with local datalib = {} -- library for data functions datalib.SaveData = function(store, key, value) if store:GetAsync(key) then -- if old, than update store:UpdateAsync(key, function() return value or DefaultMoney -- update with this new value (or default) end) else store:SetAsync(key, value) -- if not, make a new store end end Players.PlayerAdded:connect(function(plr) local key = "user_"..plr.userId local stats = Instance.new("IntValue",plr) stats.Name = "leaderstats" local level = Instance.new("StringValue",stats) level.Name = "Mode" level.Value = "Choosing" local money = Instance.new("IntValue",stats) money.Name = "Cash" money.Value = Money:GetAsync(key) or DefaultMoney money.Changed:connect(function() datalib.SaveData(Money, key, money.Value) end) end)