Advertisement
Sungmingamerpro13

Technogamerz New Main Leaderboard (STORY GAME)

Mar 21st, 2023
1,022
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 4.07 KB | None | 0 0
  1. local TeleportService = game:GetService("TeleportService")
  2. local SaveCurrency = game:GetService("DataStoreService"):GetDataStore("Wins")
  3. local SaveCurrency2 = game:GetService("DataStoreService"):GetDataStore("Rounds")
  4. local SaveCurrency3 = game:GetService("DataStoreService"):GetDataStore("Coins")
  5. local SaveCurrency4 = game:GetService("DataStoreService"):GetDataStore("Money")
  6.  
  7. local VIPGamepassId = 27333933
  8. local MoneyGamepassId = 22852448
  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.WinsValue.Value
  16.         Currency.Value = SaveCurrency:GetAsync(player.UserId) or 0
  17.  
  18.         local Currency2 = Instance.new("NumberValue",Folder)
  19.         Currency2.Name = game.ReplicatedStorage.Tags.RoundsValue.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 = SaveCurrency4:GetAsync(player.UserId)
  45.         local Money
  46.  
  47.         if previousData ~= nil then
  48.             Money = previousData
  49.         else
  50.             Money = 0
  51.             SaveCurrency3:SetAsync(player.UserId, 0)
  52.         end
  53.  
  54.         local CoinsValue = Instance.new("NumberValue", player)
  55.         CoinsValue.Name = "Money"
  56.         CoinsValue.Value = Money
  57.  
  58.         if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIPGamepassId) then
  59.             player.Coins.Value = player.Coins.Value * 2
  60.         end
  61.        
  62.         if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, MoneyGamepassId) then
  63.             player.Money.Value = player.Money.Value * 2
  64.         end
  65.     end
  66. end)
  67.  
  68. game.Players.PlayerRemoving:Connect(function(player)
  69.     if game.ReplicatedStorage.Tags.Leaderstats.Value == true then  
  70.         SaveCurrency:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.WinsValue.Value].Value)
  71.         SaveCurrency2:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.RoundsValue.Value].Value)
  72.     end
  73. end)
  74.  
  75. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  76.     print("STOPPED!")
  77.  
  78.     for i,player in pairs(game.Players:GetPlayers()) do
  79.         local value = player.Coins.Value
  80.         SaveCurrency3:SetAsync(player.UserId, value)
  81.         print("Saved data for "..player.Name)
  82.     end
  83. end)
  84.  
  85. game.Players.PlayerRemoving:Connect(function(player)
  86.     local value = player.Coins.Value
  87.  
  88.     if value ~= nil then
  89.         print("Found data to save for "..player.Name.."!")
  90.         SaveCurrency3:SetAsync(player.UserId, value)
  91.         print("Saved data for "..player.Name)
  92.     else
  93.         print("Did not manage to find data to save for "..player.Name.."!")
  94.     end
  95. end)
  96.  
  97. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  98.     print("STOPPED!")
  99.  
  100.     for i,player in pairs(game.Players:GetPlayers()) do
  101.         local value = player.Money.Value
  102.         SaveCurrency4:SetAsync(player.UserId, value)
  103.         print("Saved data for "..player.Name)
  104.     end
  105. end)
  106.  
  107. game.Players.PlayerRemoving:Connect(function(player)
  108.     local value = player.Money.Value
  109.  
  110.     if value ~= nil then
  111.         print("Found data to save for "..player.Name.."!")
  112.         SaveCurrency4:SetAsync(player.UserId, value)
  113.         print("Saved data for "..player.Name)
  114.     else
  115.         print("Did not manage to find data to save for "..player.Name.."!")
  116.     end
  117. end)
  118.  
  119. game.Players.PlayerAdded:connect(function(player)
  120.     player.CharacterAdded:connect(function(char)
  121.  
  122.         char.Humanoid.Died:connect(function()
  123.             SaveCurrency2:SetAsync(player.UserId, player.leaderstats.Rounds.Value)
  124.             player.leaderstats.Rounds.Value = player.leaderstats.Rounds.Value + 1
  125.         end)
  126.     end)
  127. end)
  128.  
  129.  
  130.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement