Advertisement
Sungmingamerpro13

My DataStore Style Break In In Lobby

Apr 17th, 2024 (edited)
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 6.66 KB | None | 0 0
  1. local TeleportService = game:GetService("TeleportService")
  2. local SaveCurrency = game:GetService("DataStoreService"):GetDataStore("Rounds")
  3. local SaveCurrency2 = game:GetService("DataStoreService"):GetDataStore("Wins")
  4. local SaveCurrency3 = game:GetService("DataStoreService"):GetDataStore("Coins")
  5. local SaveExtraLives = game:GetService("DataStoreService"):GetDataStore("Lives")
  6. local SaveRoleData = game:GetService("DataStoreService"):GetDataStore("Role")
  7. local SaveAddRounds = game:GetService("DataStoreService"):GetDataStore("AddRounds")
  8. local SaveAddWins = game:GetService("DataStoreService"):GetDataStore("AddWins")
  9.  
  10. local VIPGamepassId = "265392817"
  11.  
  12. game.Players.PlayerAdded:Connect(function(player)
  13.     if game.ReplicatedStorage.Tags.Leaderstats.Value == true then
  14.         local Folder = Instance.new("Folder",player)
  15.         Folder.Name = "leaderstats"
  16.  
  17.         local Currency = Instance.new("NumberValue",Folder)
  18.         Currency.Name = game.ReplicatedStorage.Tags.RoundsValue.Value
  19.         Currency.Value = SaveCurrency:GetAsync(player.UserId) or 0
  20.        
  21.         local AddRounds = Instance.new("NumberValue", player)
  22.         AddRounds.Name = "AddRounds"
  23.         AddRounds.Value = SaveAddRounds:GetAsync(player.UserId) or 0
  24.  
  25.         local Currency2 = Instance.new("NumberValue",Folder)
  26.         Currency2.Name = game.ReplicatedStorage.Tags.WinsValue.Value
  27.         Currency2.Value = SaveCurrency2:GetAsync(player.UserId) or 0
  28.        
  29.         local AddWins = Instance.new("NumberValue", player)
  30.         AddWins.Name = "AddWins"
  31.         AddWins.Value = SaveAddWins:GetAsync(player.UserId) or 0
  32.  
  33.         local previousData = SaveCurrency3:GetAsync(player.UserId)
  34.         local Coins
  35.  
  36.         if previousData ~= nil then
  37.             Coins = previousData
  38.         else
  39.             Coins = 0
  40.             SaveCurrency3:SetAsync(player.UserId, 0)
  41.         end
  42.  
  43.         local CoinsValue = Instance.new("NumberValue", player)
  44.         CoinsValue.Name = "Coins"
  45.         CoinsValue.Value = Coins
  46.  
  47.         local val1 = Instance.new("StringValue",player)
  48.         val1.Name = 'GotPet'
  49.         val1.Value = ''
  50.  
  51.         local val2 = Instance.new("StringValue",player)
  52.         val2.Name = 'OpenValue'
  53.         val2.Value = ''
  54.  
  55.         local previousData2 = SaveExtraLives:GetAsync(player.UserId)
  56.         local Lives
  57.        
  58.         local previousData3 = SaveRoleData:GetAsync(player.UserId)
  59.         local Role
  60.  
  61.         if previousData2 ~= nil then
  62.             Lives = previousData2
  63.         else
  64.             Lives = 0
  65.             SaveExtraLives:SetAsync(player.UserId, 0)
  66.         end
  67.        
  68.         if previousData3 ~= nil then
  69.             Role = previousData3
  70.         else
  71.             Role = player.Role.Value
  72.             SaveRoleData:SetAsync(player.UserId, player.Role.Value)
  73.         end
  74.  
  75.         local ExtraLivesValue = Instance.new("NumberValue", player)
  76.         ExtraLivesValue.Name = "Lives"
  77.         ExtraLivesValue.Value = Lives
  78.        
  79.         local RoleValue = Instance.new("StringValue", player)
  80.         RoleValue.Name = "Role"
  81.         RoleValue.Value = Role
  82.  
  83.         if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIPGamepassId) then
  84.             player.Coins.Value = player.Coins.Value * 2
  85.         end
  86.  
  87.         player.Lives.Value = 5
  88.        
  89.         if player.AddRounds.Value == 1 then
  90.             player.AddRounds.Value = player.AddRounds.Value - 1
  91.             player.leaderstats.Rounds.Value = player.leaderstats.Rounds.Value + 1
  92.         end
  93.        
  94.         if player.AddWins.Value == 1 then
  95.             player.AddWins.Value = player.AddWins.Value - 1
  96.             player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
  97.         end
  98.     end
  99. end)
  100.  
  101. game.Players.PlayerRemoving:Connect(function(player)
  102.     if game.ReplicatedStorage.Tags.Leaderstats.Value == true then  
  103.         SaveCurrency:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.RoundsValue.Value].Value)
  104.         SaveCurrency2:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.WinsValue.Value].Value)
  105.     end
  106. end)
  107.  
  108. game:BindToClose(function()
  109.     print("STOPPED!")
  110.  
  111.     for i,player in pairs(game.Players:GetPlayers()) do
  112.         local value = player.Coins.Value
  113.         SaveCurrency3:SetAsync(player.UserId, value)
  114.         print("Saved data for "..player.Name)
  115.     end
  116. end)
  117.  
  118. game.Players.PlayerRemoving:Connect(function(player)
  119.     local value = player.Coins.Value
  120.  
  121.     if value ~= nil then
  122.         print("Found data to save for "..player.Name.."!")
  123.         SaveCurrency3:SetAsync(player.UserId, value)
  124.         print("Saved data for "..player.Name)
  125.     else
  126.         print("Did not manage to find data to save for "..player.Name.."!")
  127.     end
  128. end)
  129.  
  130. game:BindToClose(function()
  131.     print("STOPPED!")
  132.  
  133.     for i, player in pairs(game.Players:GetPlayers()) do
  134.         local value2 = player.Lives.Value
  135.         SaveExtraLives:SetAsync(player.UserId, value2)
  136.     end
  137. end)
  138.  
  139. game.Players.PlayerRemoving:Connect(function(player)
  140.     local value2 = player.Lives.Value
  141.  
  142.     if value2 ~= nil then
  143.         print("Found data to save for "..player.Name.."!")
  144.         SaveExtraLives:SetAsync(player.UserId, value2)
  145.         print("Saved data for "..player.Name)
  146.     else
  147.         print("Did not manage to find data to save for "..player.Name.."!")
  148.     end
  149. end)
  150.  
  151. game:BindToClose(function()
  152.     print("STOPPED!")
  153.  
  154.     for i, player in pairs(game.Players:GetPlayers()) do
  155.         local value2 = player.Role.Value
  156.         SaveRoleData:SetAsync(player.UserId, value2)
  157.     end
  158. end)
  159.  
  160. game.Players.PlayerRemoving:Connect(function(player)
  161.     local value2 = player.Role.Value
  162.  
  163.     if value2 ~= nil then
  164.         print("Found data to save for "..player.Name.."!")
  165.         SaveRoleData:SetAsync(player.UserId, value2)
  166.         print("Saved data for "..player.Name)
  167.     else
  168.         print("Did not manage to find data to save for "..player.Name.."!")
  169.     end
  170. end)
  171.  
  172. game:BindToClose(function()
  173.     print("STOPPED!")
  174.  
  175.     for i, player in pairs(game.Players:GetPlayers()) do
  176.         local AddRoundsValue = player.AddRounds.Value
  177.         SaveAddWins:SetAsync(player.UserId, AddRoundsValue)
  178.     end
  179. end)
  180.  
  181. game.Players.PlayerRemoving:Connect(function(player)
  182.     local AddRoundsValue = player.AddRounds.Value
  183.  
  184.     if AddRoundsValue ~= nil then
  185.         print("Found data to save for "..player.Name.."!")
  186.         SaveAddRounds:SetAsync(player.UserId, AddRoundsValue)
  187.         print("Saved data for "..player.Name)
  188.     else
  189.         print("Did not manage to find data to save for "..player.Name.."!")
  190.     end
  191. end)
  192.  
  193. game:BindToClose(function()
  194.     print("STOPPED!")
  195.  
  196.     for i, player in pairs(game.Players:GetPlayers()) do
  197.         local AddWinsValue = player.AddWins.Value
  198.         SaveAddWins:SetAsync(player.UserId, AddWinsValue)
  199.     end
  200. end)
  201.  
  202. game.Players.PlayerRemoving:Connect(function(player)
  203.     local AddWinsValue = player.AddWins.Value
  204.  
  205.     if AddWinsValue ~= nil then
  206.         print("Found data to save for "..player.Name.."!")
  207.         SaveAddWins:SetAsync(player.UserId, AddWinsValue)
  208.         print("Saved data for "..player.Name)
  209.     else
  210.         print("Did not manage to find data to save for "..player.Name.."!")
  211.     end
  212. end)
  213.  
  214. local teleportData = TeleportService:GetLocalPlayerTeleportData()
  215.  
  216. if teleportData then
  217.     local Player = game.Players:GetPlayerByUserId(teleportData.PlayerName)
  218.     Player.leaderstats.Wins.Value = Player.leaderstats.Wins.Value + 1
  219. end
  220.  
  221.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement