Advertisement
Sungmingamerpro13

My DataStore Style Break In In Main Game

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