Advertisement
Sungmingamerpro13

New Wins Leaderboard Main Game

Mar 24th, 2023
1,430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 4.98 KB | None | 0 0
  1. local DatastoreService = game:GetService("DataStoreService")
  2. local TeleportService = game:GetService("TeleportService")
  3. local dVersion = 1
  4. local save = DatastoreService:GetDataStore("Wins")
  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.  
  22.     local Role = Instance.new("StringValue", player)
  23.     Role.Name = "Role"
  24.     Role.Value = player
  25. end)
  26.  
  27. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  28.     print("STOPPED!")
  29.  
  30.     for i,player in pairs(game.Players:GetPlayers()) do
  31.         local value = player.Wins.Value
  32.         save:SetAsync(player.UserId, value)
  33.         print("Saved data for "..player.Name)
  34.     end
  35. end)
  36.  
  37. game.Players.PlayerRemoving:Connect(function(player)
  38.     local value = player.Wins.Value
  39.  
  40.     if value ~= nil then
  41.         print("Found data to save for "..player.Name.."!")
  42.         save:SetAsync(player.UserId, value)
  43.         print("Saved data for "..player.Name)
  44.     else
  45.         print("Did not manage to find data to save for "..player.Name.."!")
  46.     end
  47. end)
  48.  
  49. local save2 = DatastoreService:GetDataStore("Rounds")
  50.  
  51. game.Players.PlayerAdded:Connect(function(player)
  52.     local previousData = save2:GetAsync(player.UserId) -- Returns a number value.
  53.  
  54.     local Rounds
  55.  
  56.     if previousData ~= nil then
  57.         Rounds = previousData
  58.     else
  59.         Rounds = 0
  60.         save2:SetAsync(player.UserId, 0)
  61.     end
  62.  
  63.     local coinsValue = Instance.new("IntValue", player)
  64.     coinsValue.Name = "Rounds"
  65.     coinsValue.Value = Rounds
  66. end)
  67.  
  68. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  69.     print("STOPPED!")
  70.  
  71.     for i,player in pairs(game.Players:GetPlayers()) do
  72.         local value = player.Rounds.Value
  73.         save2:SetAsync(player.UserId, value)
  74.         print("Saved data for "..player.Name)
  75.     end
  76. end)
  77.  
  78. game.Players.PlayerRemoving:Connect(function(player)
  79.     local value = player.Rounds.Value
  80.  
  81.     if value ~= nil then
  82.         print("Found data to save for "..player.Name.."!")
  83.         save2:SetAsync(player.UserId, value)
  84.         print("Saved data for "..player.Name)
  85.     else
  86.         print("Did not manage to find data to save for "..player.Name.."!")
  87.     end
  88. end)
  89. local CoinsSave = DatastoreService:GetDataStore("Coins")
  90.  
  91. game.Players.PlayerAdded:Connect(function(player)
  92.     local previousData = CoinsSave:GetAsync(player.UserId) -- Returns a number value.
  93.  
  94.     local Coins
  95.  
  96.     if previousData ~= nil then
  97.         Coins = previousData
  98.     else
  99.         Coins = 0
  100.         CoinsSave:SetAsync(player.UserId, 0)
  101.     end
  102.  
  103.     local coinsValue = Instance.new("IntValue", player)
  104.     coinsValue.Name = "Coins"
  105.     coinsValue.Value = Coins
  106.  
  107.     local val1 = Instance.new("StringValue",player)
  108.     val1.Name = 'GotPet'
  109.     val1.Value = ''
  110.  
  111.     local val2 = Instance.new("StringValue",player)
  112.     val2.Name = 'OpenValue'
  113.     val2.Value = ''
  114.  
  115.     if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 4481523680) then
  116.         player.Coins.Value = player.Coins.Value * 2
  117.     end
  118. end)
  119.  
  120. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  121.     print("STOPPED!")
  122.  
  123.     for i,player in pairs(game.Players:GetPlayers()) do
  124.         local value = player.Coins.Value
  125.         CoinsSave:SetAsync(player.UserId, value)
  126.         print("Saved data for "..player.Name)
  127.     end
  128. end)
  129.  
  130. game.Players.PlayerRemoving:Connect(function(player)
  131.     local value = player.Coins.Value
  132.  
  133.     if value ~= nil then
  134.         print("Found data to save for "..player.Name.."!")
  135.         CoinsSave:SetAsync(player.UserId, value)
  136.         print("Saved data for "..player.Name)
  137.     else
  138.         print("Did not manage to find data to save for "..player.Name.."!")
  139.     end
  140. end)
  141.  
  142. local MoneySave = DatastoreService:GetDataStore("Money")
  143.  
  144. game.Players.PlayerAdded:Connect(function(player)
  145.     local previousData = MoneySave:GetAsync(player.UserId) -- Returns a number value.
  146.  
  147.     local Money
  148.  
  149.     if previousData ~= nil then
  150.         Money = previousData
  151.     else
  152.         Money = 0
  153.         MoneySave:SetAsync(player.UserId, 0)
  154.     end
  155.  
  156.     local coinsValue = Instance.new("IntValue", player)
  157.     coinsValue.Name = "Money"
  158.     coinsValue.Value = Money
  159.  
  160. end)
  161.  
  162. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  163.     print("STOPPED!")
  164.  
  165.     for i,player in pairs(game.Players:GetPlayers()) do
  166.         local value = player.Money.Value
  167.         MoneySave:SetAsync(player.UserId, value)
  168.         print("Saved data for "..player.Name)
  169.     end
  170. end)
  171.  
  172. game.Players.PlayerRemoving:Connect(function(player)
  173.     local value = player.Money.Value
  174.  
  175.     if value ~= nil then
  176.         print("Found data to save for "..player.Name.."!")
  177.         MoneySave:SetAsync(player.UserId, value)
  178.         print("Saved data for "..player.Name)
  179.     else
  180.         print("Did not manage to find data to save for "..player.Name.."!")
  181.     end
  182. end)
  183.  
  184. game.Players.PlayerAdded:Connect(function(player)
  185.     player.CharacterAdded:Connect(function(char)
  186.         char.Died:Connect(function()
  187.             player.Rounds.Value = player.Rounds.Value + 1
  188.         end)
  189.     end)
  190. end)
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement