Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.14 KB | None | 0 0
  1. --Hey der! I just owned whoever gave RME his DP script for DoD! :DD
  2.  
  3. --Here is the script RME got:
  4.  
  5. function saveScore1(player, score1)
  6.     player:SaveNumber("Level", score1)
  7. end
  8.  
  9. function saveScore2(player, score2)
  10.     player:SaveNumber("XP", score2)
  11. end
  12.  
  13.  
  14.  
  15. function saveScore3(player, score3)
  16.     player:SaveNumber("Gold", score3)
  17. end
  18.  
  19. function loadScore1(player, money)
  20. local score1 = player:LoadNumber("Level")
  21. local stats = player:FindFirstChild("leaderstats")
  22.         if (stats ~= nil) then
  23.         local money = stats:FindFirstChild("Level")
  24.         money.Value = score1
  25.         end
  26. end
  27.  
  28. function loadScore2(player, gold)
  29. local score2 = player:LoadNumber("XP")
  30. local stats = player:FindFirstChild("leaderstats")
  31.         if (stats ~= nil) then
  32.         local gold = stats:FindFirstChild("XP")
  33.         gold.Value = score2
  34.         end
  35. end
  36.  
  37. function loadScore3(player, three)
  38. local score3 = player:LoadNumber("Gold")
  39. local stats = player:FindFirstChild("leaderstats")
  40.         if (stats ~= nil) then
  41.         local three = stats:FindFirstChild("Gold")
  42.         three.Value = score3
  43.         end
  44. end
  45.  
  46.  
  47. function onPlayerEntered(newPlayer)
  48.  
  49. if newPlayer:findFirstChild("leaderstats") ~= nil then
  50. newPlayer.leaderstats:remove()
  51. end
  52.  
  53. local stats = Instance.new("IntValue")
  54. stats.Name = "leaderstats"
  55. stats.Parent = newPlayer
  56.  
  57. expinsert = Instance.new("IntValue")
  58. expinsert.Parent = stats
  59. expinsert.Name = "Level"
  60. expinsert.Value = 0
  61.  
  62. goldinsert = Instance.new("IntValue")
  63. goldinsert.Parent = stats
  64. goldinsert.Name = "XP"
  65. goldinsert.Value = 0
  66.  
  67. threeinsert = Instance.new("IntValue")
  68. threeinsert.Parent = stats
  69. threeinsert.Name = "Gold"
  70. threeinsert.Value = 0
  71.  
  72. print"waiting for data to be ready"
  73. newPlayer:WaitForDataReady()
  74.  
  75. loadScore1(newPlayer, money)
  76. loadScore2(newPlayer, gold)
  77. loadScore3(newPlayer, three)
  78.  
  79. end
  80.  
  81. function onPlayerRemoving(player)
  82.     print("Attempting to save score for " .. player.Name)
  83.     if player.DataReady == true then
  84.  
  85.     local stats = player:FindFirstChild("leaderstats")
  86.     if (stats ~= nil) then
  87.         local money = stats:FindFirstChild("Level")
  88.  
  89.         if (money ~= nil) then
  90.             saveScore1(player, money.Value)
  91.     print("saved money")
  92.         end
  93.  
  94.         local gold = stats:FindFirstChild("XP")
  95.         if (gold ~= nil) then
  96.             saveScore2(player, gold.Value)
  97.     print("saved gold")
  98.         end
  99.     end
  100.  
  101.         local gold = stats:FindFirstChild("Gold")
  102.         if (three ~= nil) then
  103.             saveScore3(player, three.Value)
  104.         end
  105.     end
  106.  
  107.     end
  108. end
  109.  
  110.  
  111. game.Players.PlayerAdded:connect(onPlayerEntered)
  112. game.Players.PlayerRemoving:connect(onPlayerRemoving)
  113.  
  114.  
  115.  
  116. --EWWW MESSEH!!! Also, over 100 lines.
  117.  
  118. --Here's what I gave him back (He asked me to look over the above script)
  119.  
  120. game.Players.PlayerAdded:connect(function(p)
  121.     s = Instance.new("IntValue",p)
  122.     l,x,g = Instance.new("IntValue",s),Instance.new("IntValue",s),Instance.new("IntValue",s)
  123.     l.Name,x.Name,g.Name = "Lvl","XP","Gold"
  124.     p:WaitForDataReady()
  125.     l.Value,x.Value,g.Value = p:LoadNumber("Lvl"),p:LoadNumber("XP"),p:LoadNumber("Gold")
  126.     l.Changed:connect(function()
  127.         p:SaveNumber("Lvl",l.Value)
  128.     end)
  129.     x.Changed:connect(function()
  130.         p:SaveNumber("XP",x.Value)
  131.     end)
  132.     g.Changed:connect(function()
  133.         p:SaveNumber("Gold",g.Value)
  134.     end)
  135. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement