local datastore = game:GetService("DataStoreService") local ds2 = datastore:GetDataStore("CashSaveSystem")
game.Players.PlayerAdded:Connect(function(plr) local folder = Instance.new("Folder", plr) folder.Name = "leaderstats" local cash = Instance.new("IntValue", folder) cash.Name = "Cash"
cash.Value = ds2:GetAsync(plr.UserId) or 0 ds2:SetAsnyc(plr.UserId, cash.Value)
end)
Put in the ServerScriptService.
The ServerScriptService is basically the go-to when it comes to data saving, as it functions for all players and to have separate data files.