Advertisement
Sungmingamerpro13

New Wins Leaderboard Lobby Game

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