Fr4st3yyt

Data Store

Jul 16th, 2022
12,447
-1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 1
  1. local ds = game:GetService("DataStoreService"):GetGlobalDataStore()
  2. game.Players.PlayerAdded:Connect(function(plr)
  3. wait()
  4. local plrkey = "id_"..plr.UserId
  5. local save1 = plr.leaderstats.Wins
  6.  
  7. local Saved = ds:GetAsync(plrkey)
  8. if Saved then
  9. save1.Value = Saved[1]
  10. else
  11. local NumberForSaving = {save1.Value}
  12. ds:GetAsync(plrkey, NumberForSaving)
  13. end
  14. end)
  15.  
  16. game.Players.PlayerRemoving:Connect(function(plr)
  17. ds:SetAsync("id_"..plr.UserId, {plr.leaderstats.Wins.Value})
  18. end)
Advertisement
Add Comment
Please, Sign In to add comment