Advertisement
Sungmingamerpro13

My DataStore Style Break In In Main Game

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