Advertisement
Sungmingamerpro13

Daycare Story Wins and Rounds(Lobby)

Sep 22nd, 2021
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. local DatastoreService = game:GetService("DataStoreService")
  2. local TeleportService = game:GetService("TeleportService")
  3. local dVersion = 1
  4. local save = DatastoreService:GetOrderedDataStore("Wins "..dVersion)
  5.  
  6. game.Players.PlayerAdded:Connect(function(player)
  7. local previousData = save:GetAsync(player.UserId) -- Returns a number value.
  8.  
  9. local Wins
  10.  
  11. if previousData ~= nil then
  12. Wins = previousData
  13. else
  14. Wins = 0
  15. save:SetAsync(player.UserId, 0)
  16. end
  17.  
  18. local coinsValue = Instance.new("IntValue", player)
  19. coinsValue.Name = "Wins"
  20. coinsValue.Value = Wins
  21. end)
  22.  
  23. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  24. print("STOPPED!")
  25.  
  26. for i,player in pairs(game.Players:GetPlayers()) do
  27. local value = player.Wins.Value
  28. save:SetAsync(player.UserId, value)
  29. print("Saved data for "..player.Name)
  30. end
  31. end)
  32.  
  33. game.Players.PlayerRemoving:Connect(function(player)
  34. local value = player.Wins.Value
  35.  
  36. if value ~= nil then
  37. print("Found data to save for "..player.Name.."!")
  38. save:SetAsync(player.UserId, value)
  39. print("Saved data for "..player.Name)
  40. else
  41. print("Did not manage to find data to save for "..player.Name.."!")
  42. end
  43. end)
  44.  
  45. local save2 = DatastoreService:GetOrderedDataStore("Rounds "..dVersion)
  46.  
  47. game.Players.PlayerAdded:Connect(function(player)
  48. local previousData = save2:GetAsync(player.UserId) -- Returns a number value.
  49.  
  50. local Rounds
  51.  
  52. if previousData ~= nil then
  53. Rounds = previousData
  54. else
  55. Rounds = 0
  56. save2:SetAsync(player.UserId, 0)
  57. end
  58.  
  59. local coinsValue = Instance.new("IntValue", player)
  60. coinsValue.Name = "Rounds"
  61. coinsValue.Value = Rounds
  62. end)
  63.  
  64. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  65. print("STOPPED!")
  66.  
  67. for i,player in pairs(game.Players:GetPlayers()) do
  68. local value = player.Rounds.Value
  69. save2:SetAsync(player.UserId, value)
  70. print("Saved data for "..player.Name)
  71. end
  72. end)
  73.  
  74. game.Players.PlayerRemoving:Connect(function(player)
  75. local value = player.Rounds.Value
  76.  
  77. if value ~= nil then
  78. print("Found data to save for "..player.Name.."!")
  79. save2:SetAsync(player.UserId, value)
  80. print("Saved data for "..player.Name)
  81. else
  82. print("Did not manage to find data to save for "..player.Name.."!")
  83. end
  84. end)
  85. local CoinsSave = DatastoreService:GetOrderedDataStore("Coins "..dVersion)
  86.  
  87. game.Players.PlayerAdded:Connect(function(player)
  88. local previousData = CoinsSave:GetAsync(player.UserId) -- Returns a number value.
  89.  
  90. local Coins
  91.  
  92. if previousData ~= nil then
  93. Coins = previousData
  94. else
  95. Coins = 0
  96. CoinsSave:SetAsync(player.UserId, 0)
  97. end
  98.  
  99. local coinsValue = Instance.new("IntValue", player)
  100. coinsValue.Name = "Coins"
  101. coinsValue.Value = Coins
  102.  
  103. local val1 = Instance.new("StringValue",player)
  104. val1.Name = 'GotPet'
  105. val1.Value = ''
  106.  
  107. local val2 = Instance.new("StringValue",player)
  108. val2.Name = 'OpenValue'
  109. val2.Value = ''
  110. end)
  111.  
  112. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  113. print("STOPPED!")
  114.  
  115. for i,player in pairs(game.Players:GetPlayers()) do
  116. local value = player.Coins.Value
  117. CoinsSave:SetAsync(player.UserId, value)
  118. print("Saved data for "..player.Name)
  119. end
  120. end)
  121.  
  122. game.Players.PlayerRemoving:Connect(function(player)
  123. local value = player.Coins.Value
  124.  
  125. if value ~= nil then
  126. print("Found data to save for "..player.Name.."!")
  127. CoinsSave:SetAsync(player.UserId, value)
  128. print("Saved data for "..player.Name)
  129. else
  130. print("Did not manage to find data to save for "..player.Name.."!")
  131. end
  132. end)
  133. local teleportData = TeleportService:GetLocalPlayerTeleportData()
  134.  
  135. if teleportData then
  136. local Player = game.Players:GetPlayerByUserId(teleportData.PlayerName)
  137. Player:WaitForChild('Wins').Value = Player.Wins.Value + 1
  138. end
  139.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement