SHARE
TWEET

Untitled

a guest Sep 20th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Configs --
  2. Save1Enabled = true -- If you want the save to be turned off or on (True/False)
  3. Save2Enabled = true -- If you want the save to be turned off or on (True/False)
  4.  
  5. Save1Name = "Cash"  -- What the save will be called on the leaderboard
  6. Save2Name = "Quirk" -- What the save will be called on the leaderboard
  7.  
  8. Save1Money = 0 -- How much the player will start off with.
  9. Save2Money = Quirkless -- How much the player will start off with. 
  10.  
  11. -- Please only edit things in configs otherwise script will  break --
  12.  
  13.  
  14. ------------------------------------------
  15. --DO NOT EDIT ANYTHING BELOW THIS LINE! --
  16. ------------------------------------------
  17.  
  18. -- Variables | DO NOT EDIT THIS --
  19. DSS = game:GetService("DataStoreService")
  20. local ds1 = DSS:GetDataStore("DataSave1")
  21. local ds2 = DSS:GetDataStore("DataSave2")
  22.  
  23. -- Script | DO NOT EDIT THIS --
  24. game.Players.PlayerAdded:Connect(function(plr)
  25.      local folder = Instance.new("Folder", plr)
  26.      folder.Name = "leaderstats"
  27.  
  28. -- Saves | DO NOT EDIT THIS --
  29.     if Save1Enabled == true then
  30.         local SaveInt1 = Instance.new("IntValue", folder)
  31.          SaveInt1.Name = Save1Name
  32.         SaveInt1.Value = Save1Money
  33.     end
  34.    
  35.     if Save2Enabled == true then
  36.         local SaveInt2 = Instance.new("IntValue", folder)
  37.          SaveInt2.Name = Save2Name
  38.         SaveInt2.Value = Save2Money
  39.     end
  40.    
  41. -- GetAsync | DO NOT EDIT THIS --
  42.     if Save1Enabled == true then
  43.         plr.leaderstats[Save1Name].Value = ds1:GetAsync(plr.UserId) or 0
  44.          ds1:SetAsync(plr.UserId, plr.leaderstats[Save1Name].Value) or
  45.     end
  46.      
  47.     if Save2Enabled == true then
  48.         plr.leaderstats[Save2Name].Value = ds2:GetAsync(plr.UserId) or
  49.          ds2:SetAsync(plr.UserId, plr.leaderstats[Save2Name].Value)
  50.     end
  51.    
  52. -- Player Leaves Saving | DO NOT EDIT THIS --
  53. game.Players.PlayerRemoving:Connect(function(plr)
  54.    
  55.     if Save1Enabled == true then
  56.         ds1:SetAsync(plr.UserId, plr.leaderstats[Save1Name].Value)
  57.     end
  58.    
  59.     if Save2Enabled == true then
  60.         ds2:SetAsync(plr.UserId, plr.leaderstats[Save2Name].Value)
  61.     end
  62.    
  63. end)
  64.  
  65. -- Values Change Saving --
  66. if Save1Enabled == true then
  67.     plr.leaderstats[Save1Name].Changed:Connect(function()
  68.           ds1:SetAsync(plr.UserId, plr.leaderstats[Save2Name].Value)
  69.     end)
  70. end
  71.  
  72. if Save2Enabled == true then
  73.      plr.leaderstats[Save2Name].Changed:Connect(function()
  74.           ds2:SetAsync(plr.UserId, plr.leaderstats[Save2Name].Value)
  75.     end)
  76. end
  77. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top