Advertisement
Sungmingamerpro13

My New Wins and Rounds With VIP 20.1.62(Main Game)

Sep 12th, 2022 (edited)
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.71 KB | None | 0 0
  1. local Players = game:GetService('Players')
  2. local TeleportService = game:GetService("TeleportService")
  3. local dVersion = 1
  4.  
  5. local WinsDataStore = game:GetService("DataStoreService"):GetDataStore("Wins")
  6. local RoundsDataStore = game:GetService("DataStoreService"):GetDataStore("Rounds")
  7.  
  8. local VIP = 81050904
  9.  
  10. Players.PlayerAdded:Connect(function(Player)
  11.  
  12. local Stats = Instance.new('Folder')
  13. Stats.Name = 'leaderstats'
  14. Stats.Parent = Player
  15.  
  16. local Wins = Instance.new('IntValue')
  17. Wins.Name = 'Wins'
  18. Wins.Parent = Stats
  19.  
  20. local Rounds = Instance.new("IntValue")
  21. Rounds.Name = "Rounds"
  22. Rounds.Parent = Stats
  23.  
  24.  
  25. local Data = WinsDataStore:GetAsync(Player.UserId)
  26. local Data2 = RoundsDataStore:GetAsync(Player.UserId)
  27.  
  28.  
  29. if Data then
  30. for name, value in pairs(Data.Stats) do
  31. Stats[name].Value = value
  32. end
  33.  
  34. end
  35.  
  36. if Data2 then
  37. for name, value in pairs(Data2.Stats) do
  38. Stats[name].Value = value
  39. end
  40.  
  41. end
  42.  
  43. end)
  44.  
  45. Players.PlayerRemoving:Connect(function(Player)
  46. local SaveData = {Stats = {}}
  47. local SaveData2 = {Stats = {}}
  48.  
  49.  
  50. for _, stat in pairs(Player.leaderstats:GetChildren()) do
  51. SaveData.Stats[stat.Name] = stat.Value
  52. end
  53. for _, stat2 in pairs(Player.leaderstats:GetChildren()) do
  54. SaveData2.Stats[stat2.Name] = stat2.Value
  55. end
  56.  
  57.  
  58.  
  59. WinsDataStore:SetAsync(Player.UserId,SaveData)
  60. RoundsDataStore:SetAsync(Player.UserId,SaveData2)
  61.  
  62. end)
  63.  
  64. game:BindToClose(function()
  65. for _, Player in pairs(game.Players:GetPlayers()) do
  66. local SaveData = {Stats = {}}
  67. local SaveData2 = {Stats = {}}
  68.  
  69.  
  70. for _,stat in pairs(Player.leaderstats:GetChildren()) do
  71. SaveData.Stats[stat.Name] = stat.Value
  72. end
  73. for _,stat2 in pairs(Player.leaderstats:GetChildren()) do
  74. SaveData2.Stats[stat2.Name] = stat2.Value
  75. end
  76.  
  77.  
  78. WinsDataStore:SetAsync(Player.UserId,SaveData)
  79. RoundsDataStore:SetAsync(Player.UserId,SaveData2)
  80. end
  81.  
  82. wait(2)
  83. end)
  84. local CoinsSave = game:GetService("DataStoreService"):GetOrderedDataStore("Coins "..dVersion)
  85.  
  86. game.Players.PlayerAdded:Connect(function(player)
  87. local previousData = CoinsSave:GetAsync(player.UserId) -- Returns a number value.
  88.  
  89. local Coins
  90.  
  91. if previousData ~= nil then
  92. Coins = previousData
  93. else
  94. Coins = 0
  95. CoinsSave:SetAsync(player.UserId, 0)
  96. end
  97.  
  98. local coinsValue = Instance.new("IntValue", player)
  99. coinsValue.Name = "Coins"
  100. coinsValue.Value = Coins
  101.  
  102. local val1 = Instance.new("StringValue",player)
  103. val1.Name = 'GotPet'
  104. val1.Value = ''
  105.  
  106. local val2 = Instance.new("StringValue",player)
  107. val2.Name = 'OpenValue'
  108. val2.Value = ''
  109. end)
  110.  
  111. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  112. print("STOPPED!")
  113.  
  114. for i,player in pairs(game.Players:GetPlayers()) do
  115. local value = player.Coins.Value
  116. CoinsSave:SetAsync(player.UserId, value)
  117. print("Saved data for "..player.Name)
  118. end
  119. end)
  120.  
  121. game.Players.PlayerRemoving:Connect(function(player)
  122. local value = player.Coins.Value
  123.  
  124. if value ~= nil then
  125. print("Found data to save for "..player.Name.."!")
  126. CoinsSave:SetAsync(player.UserId, value)
  127. print("Saved data for "..player.Name)
  128. else
  129. print("Did not manage to find data to save for "..player.Name.."!")
  130. end
  131. end)
  132.  
  133. local SaveExtraLives = game:GetService("DataStoreService"):GetOrderedDataStore("Lives "..dVersion)
  134.  
  135. game.Players.PlayerAdded:Connect(function(player)
  136. local previousData = CoinsSave:GetAsync(player.UserId) -- Returns a number value.
  137.  
  138. local Lives
  139.  
  140. if previousData ~= nil then
  141. Lives = previousData
  142. else
  143. Lives = 0
  144. CoinsSave:SetAsync(player.UserId, 0)
  145. end
  146.  
  147. local coinsValue = Instance.new("IntValue", player)
  148. coinsValue.Name = "Lives"
  149. coinsValue.Value = Lives
  150. end)
  151.  
  152. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  153. print("STOPPED!")
  154.  
  155. for i,player in pairs(game.Players:GetPlayers()) do
  156. local value = player.Lives.Value
  157. SaveExtraLives:SetAsync(player.UserId, value)
  158. print("Saved data for "..player.Name)
  159. end
  160. end)
  161.  
  162. game.Players.PlayerRemoving:Connect(function(player)
  163. local value = player.Lives.Value
  164.  
  165. if value ~= nil then
  166. print("Found data to save for "..player.Name.."!")
  167. SaveExtraLives:SetAsync(player.UserId, value)
  168. print("Saved data for "..player.Name)
  169. else
  170. print("Did not manage to find data to save for "..player.Name.."!")
  171. end
  172. end)
  173.  
  174. game.Players.PlayerAdded:connect(function(player)
  175. player.CharacterAdded:connect(function(char)
  176.  
  177. char.Humanoid.Died:connect(function()
  178. RoundsDataStore:SetAsync(player.UserId, player.leaderstats.Rounds.Value)
  179. SaveExtraLives:SetAsync(player.UserId, player.Lives.Value)
  180. player.Lives.Value = player.Lives.Value - 1
  181. player.leaderstats.Rounds.Value = player.leaderstats.Rounds.Value + 1
  182. end)
  183. end)
  184. end)
  185.  
  186.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement