Advertisement
Sungmingamerpro13

My Break In STORY Leaderboard Main

Oct 16th, 2023 (edited)
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 6.08 KB | Source Code | 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.  
  7. local VIPGamepassId = "265392817"
  8.  
  9. game.Players.PlayerAdded:Connect(function(player)
  10.     if game.ReplicatedStorage.Tags.Leaderstats.Value == true then
  11.         local Folder = Instance.new("Folder",player)
  12.         Folder.Name = "leaderstats"
  13.  
  14.         local Currency = Instance.new("NumberValue",Folder)
  15.         Currency.Name = game.ReplicatedStorage.Tags.RoundsValue.Value
  16.         Currency.Value = SaveCurrency:GetAsync(player.UserId) or 0
  17.  
  18.         local Currency2 = Instance.new("NumberValue",Folder)
  19.         Currency2.Name = game.ReplicatedStorage.Tags.WinsValue.Value
  20.         Currency2.Value = SaveCurrency2:GetAsync(player.UserId) or 0
  21.  
  22.         local previousData = SaveCurrency3:GetAsync(player.UserId)
  23.         local Coins
  24.  
  25.         if previousData ~= nil then
  26.             Coins = previousData
  27.         else
  28.             Coins = 0
  29.             SaveCurrency3:SetAsync(player.UserId, 0)
  30.         end
  31.  
  32.         local CoinsValue = Instance.new("NumberValue", player)
  33.         CoinsValue.Name = "Coins"
  34.         CoinsValue.Value = Coins
  35.  
  36.         local val1 = Instance.new("StringValue",player)
  37.         val1.Name = 'GotPet'
  38.         val1.Value = ''
  39.  
  40.         local val2 = Instance.new("StringValue",player)
  41.         val2.Name = 'OpenValue'
  42.         val2.Value = ''
  43.  
  44.         local previousData2 = SaveExtraLives:GetAsync(player.UserId)
  45.         local Lives
  46.  
  47.         if previousData2 ~= nil then
  48.             Lives = previousData2
  49.         else
  50.             Lives = 0
  51.             SaveExtraLives:SetAsync(player.UserId, 0)
  52.         end
  53.  
  54.         local ExtraLivesValue = Instance.new("NumberValue", player)
  55.         ExtraLivesValue.Name = "Lives"
  56.         ExtraLivesValue.Value = Lives
  57.  
  58.         local Role = Instance.new("StringValue", player)
  59.         Role.Parent = player
  60.         Role.Name = "Role"
  61.         Role.Value = ""
  62.        
  63.         if player.Role.Value >= "Normal Kid" then
  64.             player.Character.Humanoid.MaxHealth = 100
  65.             player.Character.Humanoid.BodyDepthScale.Value = 0.7
  66.             player.Character.Humanoid.BodyHeightScale.Value = 0.7
  67.             player.Character.Humanoid.BodyWidthScale.Value = 0.6
  68.         end
  69.         if player.Role.Value == "Protector 1" then
  70.             player.Character.Humanoid.MaxHealth = 100
  71.             player.Character.Humanoid.BodyDepthScale.Value = 1
  72.             player.Character.Humanoid.BodyHeightScale.Value = 1
  73.             player.Character.Humanoid.BodyWidthScale.Value = 1
  74.         end
  75.         if player.Role.Value == "Medic" then
  76.             player.Character.Humanoid.MaxHealth = 100
  77.             player.Character.Humanoid.BodyDepthScale.Value = 1
  78.             player.Character.Humanoid.BodyHeightScale.Value = 1
  79.             player.Character.Humanoid.BodyWidthScale.Value = 1
  80.         end
  81.         if player.Role.Value == "Protector 2" then
  82.             player.Character.Humanoid.MaxHealth = 100
  83.             player.Character.Humanoid.BodyDepthScale.Value = 1
  84.             player.Character.Humanoid.BodyHeightScale.Value = 1
  85.             player.Character.Humanoid.BodyWidthScale.Value = 1
  86.         end
  87.         if player.Role.Value == "Protector 3" then
  88.             player.Character.Humanoid.MaxHealth = 100
  89.             player.Character.Humanoid.BodyDepthScale.Value = 1
  90.             player.Character.Humanoid.BodyHeightScale.Value = 1
  91.             player.Character.Humanoid.BodyWidthScale.Value = 1
  92.         end
  93.         if player.Role.Value == "IceCreamBoy" 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.         end
  99.         if player.Role.Value == "Fighter" then
  100.             player.Character.Humanoid.MaxHealth = 100
  101.             player.Character.Humanoid.BodyDepthScale.Value = 0.7
  102.             player.Character.Humanoid.BodyHeightScale.Value = 0.7
  103.             player.Character.Humanoid.BodyWidthScale.Value = 0.6
  104.         end
  105.         if player.Role.Value == "PREMIUM" then
  106.             player.Character.Humanoid.MaxHealth = 100
  107.             player.Character.Humanoid.BodyDepthScale.Value = 1
  108.             player.Character.Humanoid.BodyHeightScale.Value = 1
  109.             player.Character.Humanoid.BodyWidthScale.Value = 1
  110.         end
  111.  
  112.  
  113.         if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIPGamepassId) then
  114.             player.Coins.Value = player.Coins.Value * 2
  115.         end
  116.  
  117.         player.Lives.Value = 5
  118.     end
  119. end)
  120.  
  121. game.Players.PlayerRemoving:Connect(function(player)
  122.     if game.ReplicatedStorage.Tags.Leaderstats.Value == true then  
  123.         SaveCurrency:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.RoundsValue.Value].Value)
  124.         SaveCurrency2:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.WinsValue.Value].Value)
  125.     end
  126. end)
  127.  
  128. game:BindToClose(function()
  129.     print("STOPPED!")
  130.  
  131.     for i,player in pairs(game.Players:GetPlayers()) do
  132.         local value = player.Coins.Value
  133.         SaveCurrency3:SetAsync(player.UserId, value)
  134.         print("Saved data for "..player.Name)
  135.     end
  136. end)
  137.  
  138. game.Players.PlayerRemoving:Connect(function(player)
  139.     local value = player.Coins.Value
  140.  
  141.     if value ~= nil then
  142.         print("Found data to save for "..player.Name.."!")
  143.         SaveCurrency3:SetAsync(player.UserId, value)
  144.         print("Saved data for "..player.Name)
  145.     else
  146.         print("Did not manage to find data to save for "..player.Name.."!")
  147.     end
  148. end)
  149.  
  150. game:BindToClose(function()
  151.     print("STOPPED!")
  152.  
  153.     for i, player in pairs(game.Players:GetPlayers()) do
  154.         local value2 = player.Lives.Value
  155.         SaveExtraLives:SetAsync(player.UserId, value2)
  156.     end
  157. end)
  158.  
  159. game.Players.PlayerRemoving:Connect(function(player)
  160.     local value2 = player.Lives.Value
  161.  
  162.     if value2 ~= nil then
  163.         print("Found data to save for "..player.Name.."!")
  164.         SaveExtraLives:SetAsync(player.UserId, value2)
  165.         print("Saved data for "..player.Name)
  166.     else
  167.         print("Did not manage to find data to save for "..player.Name.."!")
  168.     end
  169. end)
  170.  
  171. game.Players.PlayerAdded:connect(function(player)
  172.     player.CharacterAdded:connect(function(char)
  173.  
  174.         char.Humanoid.Died:connect(function()
  175.             SaveCurrency:SetAsync(player.UserId, player.leaderstats.Rounds.Value)
  176.             SaveExtraLives:SetAsync(player.UserId, player.Lives.Value)
  177.             player.leaderstats.Rounds.Value = player.leaderstats.Rounds.Value + 1
  178.             player.Lives.Value = player.Lives.Value - 1
  179.         end)
  180.     end)
  181. end)
  182.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement