Advertisement
Dbloxia

Load/Save Gui

Jun 22nd, 2018
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. --Load script
  2. function loadScore(plyr, clickCounter)
  3.  
  4. local score = plyr:LoadNumber("stage")
  5.  
  6. if not score == 0 then
  7. clickCounter.Value = score
  8. else
  9. print("Nothing to load../..score was 0")
  10. end
  11.  
  12. end
  13.  
  14.  
  15.  
  16. function onClicked()
  17.  
  18. player = script.Parent.Parent.Parent.Parent.Parent
  19. player:WaitForDataReady()
  20. if player.DataReady == true then
  21. loadScore(player, player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value))
  22. player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value).Value = player:LoadNumber("stage")
  23. m = Instance.new("Message",player.PlayerGui)
  24. m.Text = script.Parent.Parent.Parent.Configuration.Type.Value.. " loaded!"
  25. script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0
  26. game:service("Debris"):AddItem(m, 3)
  27. else
  28. m = Instance.new("Message",player.PlayerGui)
  29. m.Text = "Wait until DataReady!"
  30. game:service("Debris"):AddItem(m, 3)
  31. end
  32. end
  33.  
  34. script.Parent.MouseButton1Click:connect(onClicked)
  35. --Save script
  36. function SaveScore(plyr, score)
  37. plyr:SaveNumber("stage", score)
  38. end
  39.  
  40.  
  41.  
  42.  
  43. function onClicked()
  44.  
  45. player = script.Parent.Parent.Parent.Parent.Parent
  46. player:WaitForDataReady()
  47. if player.DataReady == true then
  48. SaveScore(player, player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value).Value)
  49. m = Instance.new("Message",player.PlayerGui)
  50. m.Text = script.Parent.Parent.Parent.Configuration.Type.Value.. " saved!"
  51. game:service("Debris"):AddItem(m, 3)
  52. else
  53. m = Instance.new("Message",player.PlayerGui)
  54. m.Text = "Wait until DataReady!"
  55. game:service("Debris"):AddItem(m, 3)
  56.  
  57. end
  58. end
  59.  
  60. script.Parent.MouseButton1Click:connect(onClicked)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement