Advertisement
Sungmingamerpro13

FiredRBLXMan and Hammam DataStore Lobby

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