Advertisement
Sungmingamerpro13

My New Leaderstats Main Game (STORY GAME V7.10)

Sep 3rd, 2024
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 4.13 KB | None | 0 0
  1. local TeleportService = game:GetService("TeleportService")
  2. local AddRoundsDataStore = game:GetService("DataStoreService"):GetDataStore("AddRounds")
  3. local AddWinsDataStore = game:GetService("DataStoreService"):GetDataStore("AddWins")
  4. local SaveCurrency3 = game:GetService("DataStoreService"):GetDataStore("Coins")
  5. local SaveExtraLives = game:GetService("DataStoreService"):GetDataStore("Lives")
  6.  
  7. local VIPGamepassId = 64418164
  8.  
  9. game.Players.PlayerAdded:Connect(function(player)
  10.     if game.ReplicatedStorage.Tags.Leaderstats.Value == true then
  11.        
  12.         local AddRounds = Instance.new("NumberValue", player)
  13.         AddRounds.Name = "AddRounds"
  14.         AddRounds.Value = AddRoundsDataStore:GetAsync(player.UserId) or 0
  15.        
  16.         local AddWins = Instance.new("NumberValue", player)
  17.         AddWins.Name = "AddWins"
  18.         AddWins.Value = AddWinsDataStore:GetAsync(player.UserId) or 0
  19.  
  20.         local previousData = SaveCurrency3:GetAsync(player.UserId)
  21.         local Coins
  22.  
  23.         if previousData ~= nil then
  24.             Coins = previousData
  25.         else
  26.             Coins = 0
  27.             SaveCurrency3:SetAsync(player.UserId, 0)
  28.         end
  29.  
  30.         local CoinsValue = Instance.new("NumberValue", player)
  31.         CoinsValue.Name = "Coins"
  32.         CoinsValue.Value = Coins
  33.  
  34.         local val1 = Instance.new("StringValue",player)
  35.         val1.Name = 'GotPet'
  36.         val1.Value = ''
  37.  
  38.         local val2 = Instance.new("StringValue",player)
  39.         val2.Name = 'OpenValue'
  40.         val2.Value = ''
  41.  
  42.         local previousData2 = SaveExtraLives:GetAsync(player.UserId)
  43.         local Lives
  44.  
  45.         if previousData2 ~= nil then
  46.             Lives = previousData2
  47.         else
  48.             Lives = 0
  49.             SaveExtraLives:SetAsync(player.UserId, 0)
  50.         end
  51.  
  52.         local ExtraLivesValue = Instance.new("NumberValue", player)
  53.         ExtraLivesValue.Name = "Lives"
  54.         ExtraLivesValue.Value = Lives
  55.  
  56.         if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIPGamepassId) then
  57.             player.Coins.Value = player.Coins.Value * 2
  58.         end
  59.        
  60.         local Rank = Instance.new("StringValue", player)
  61.         Rank.Name = "Rank"
  62.         Rank.Value = "Classic"
  63.  
  64.         if Rank.Value == "Classic" then
  65.             local Shirt = script.Classic:WaitForChild("Shirt"):Clone()
  66.             local Pants = script.Classic:WaitForChild("Pants"):Clone()
  67.             if (player) and (player.Character) then
  68.                 for _, Item in pairs(player.Character:GetChildren()) do
  69.                     if Item:IsA("Shirt") then
  70.                         Item:Destroy()
  71.                         Shirt.Parent = player.Character
  72.                     elseif Item:IsA("Pants") then
  73.                         Item:Destroy()
  74.                     end
  75.                     Shirt.Parent = player.Character
  76.                     Pants.Parent = player.Character
  77.                 end
  78.             end
  79.         end
  80.     end
  81. end)
  82.  
  83. game.Players.PlayerRemoving:Connect(function(player)
  84.     if game.ReplicatedStorage.Tags.Leaderstats.Value == true then
  85.         AddRoundsDataStore:SetAsync(player.UserId, player.AddRounds.Value)
  86.         AddWinsDataStore:SetAsync(player.UserId, player.AddWins.Value)
  87.     end
  88. end)
  89.  
  90. game:BindToClose(function()
  91.     print("STOPPED!")
  92.  
  93.     for i,player in pairs(game.Players:GetPlayers()) do
  94.         local value = player.Coins.Value
  95.         SaveCurrency3:SetAsync(player.UserId, value)
  96.         print("Saved data for "..player.Name)
  97.     end
  98. end)
  99.  
  100. game.Players.PlayerRemoving:Connect(function(player)
  101.     local value = player.Coins.Value
  102.  
  103.     if value ~= nil then
  104.         print("Found data to save for "..player.Name.."!")
  105.         SaveCurrency3:SetAsync(player.UserId, value)
  106.         print("Saved data for "..player.Name)
  107.     else
  108.         print("Did not manage to find data to save for "..player.Name.."!")
  109.     end
  110. end)
  111.  
  112. game:BindToClose(function()
  113.     print("STOPPED!")
  114.  
  115.     for i, player in pairs(game.Players:GetPlayers()) do
  116.         local value2 = player.Lives.Value
  117.         SaveExtraLives:SetAsync(player.UserId, value2)
  118.     end
  119. end)
  120.  
  121. game.Players.PlayerRemoving:Connect(function(player)
  122.     local value2 = player.Lives.Value
  123.  
  124.     if value2 ~= nil then
  125.         print("Found data to save for "..player.Name.."!")
  126.         SaveExtraLives:SetAsync(player.UserId, value2)
  127.         print("Saved data for "..player.Name)
  128.     else
  129.         print("Did not manage to find data to save for "..player.Name.."!")
  130.     end
  131. end)
  132.  
  133. game.Players.PlayerAdded:connect(function(player)
  134.     player.CharacterAdded:connect(function(char)
  135.  
  136.         char.Humanoid.Died:connect(function()
  137.             player.Lives.Value = player.Lives.Value - 1
  138.             player.AddRounds.Value = player.AddRounds.Value + 1
  139.         end)
  140.     end)
  141. end)
  142.  
  143.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement