Guest User

Untitled

a guest
Aug 13th, 2019
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. //this is the general format of the player savedata
  2. local data = {}
  3. game.Players.PlayerAdded:Connect(function(player)
  4. local plrDat = DataStore:GetAsync(player.UserId)
  5. if plrDat ~= nil then
  6. data[tostring(player.UserId)] = plrDat
  7. else
  8. data[tostring(player.UserId)] = {
  9. ['Tier'] = 1,
  10. ['Level'] = 1,
  11. ['EXP'] = 0,
  12. ['Name'] = "John Doe",
  13. ['Appearance'] = {//basically texture values and colors converted to hashes with integers here},
  14. ['Genetics'] = {
  15. //redacted
  16. },
  17. ['PrimaryTown'] = "Dragan",
  18. ['Statistics'] = {
  19. ['Aptitude'] = 1,
  20. ['Intelligence'] = 1,
  21. ['Power'] = 1,
  22. ['Strength'] = 1,
  23. ['Agility'] = 1,
  24. },
  25. ['StatisticCache'] = { //stats earned but not redeemed yet
  26. ['Aptitude'] = 0,
  27. ['Intelligence'] = 0,
  28. ['Power'] = 0,
  29. ['Strength'] = 0,
  30. ['Agility'] = 0,
  31. },
  32. ['Abilities'] = { },
  33. ['EquippedAbilities'] = {
  34. ['Slot1'] = nil,
  35. ['Slot2'] = nil,
  36. ['Slot3'] = nil,
  37. ['Slot4'] = nil,
  38. },
  39. ['Perks'] = { },
  40. ['EquippedPerks'] = {
  41. ['Perk1'] = nil,
  42. ['Perk2'] = nil,
  43. ['Perk3'] = nil,
  44. ['Perk4'] = nil,
  45. ['Perk5'] = nil,
  46. },
  47. }
  48. end
  49. end)
  50.  
  51. game.Players.PlayerRemoving:Connect(function(player)
  52. DataStore:SetAsync(player.UserId, data[tostring(player.UserId)])
  53. end)
  54.  
  55. --alternatively with UpdateAsync but the problem still occurs and I don't think it's any better than SetAsync in this context
  56. --[[game.Players.PlayerRemoving:Connect(function(player)
  57. DataStore:UpdateAsync(player.UserId, function(oldData)
  58. return data[tostring(player.UserId)]
  59. end)
  60. end)]]
Advertisement
Add Comment
Please, Sign In to add comment