Guest User

Statistics-handling Script

a guest
Apr 28th, 2016
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.61 KB | None | 0 0
  1. game.Players.LocalPlayer:WaitForChild(script.Parent)
  2.  
  3. --< [[ World Variables ]] >--
  4.  
  5. PlayerGui = game.Players.LocalPlayer.PlayerGui
  6.  
  7.  
  8. --< [[ Custom Variables ]] >--
  9.  
  10. -- Kin --
  11. Kin = script.Parent.Values.Kin
  12.  
  13. KinDisplay = PlayerGui.HeadsUpDisplay.Main.Kin
  14.  
  15. -- Experience --
  16. Level = script.Parent.Values.Level
  17. Experience = Level.Experience
  18. MaxExperience = Level.MaxExperience
  19.  
  20. ExperienceBar = PlayerGui.HeadsUpDisplay.Main.Experience
  21. LevelDisplay = PlayerGui.HeadsUpDisplay.Main.Level
  22.  
  23. ExpSize = UDim2.new(0, 11, 0, (Experience.Value * 63)/MaxExperience.Value * -1)
  24.  
  25. MaxE = {
  26.     50, 63, 78, 98, 122,                    -- Lv 1 - 5
  27.     153, 191, 238, 298, 373,                -- Lv 6 - 10
  28.     466, 582, 728, 910, 1137,               -- Lv 11 - 15
  29.     1421, 1776, 2221, 2776, 3470            -- Lv 16 - 20
  30. }
  31.  
  32. -- Magic --
  33. Magic = script.Parent.Values.Magic
  34. MagicRegen = Magic.MagicRegen
  35. MaxMagic = Magic.MaxMagic
  36.  
  37. MagicBar = PlayerGui.HeadsUpDisplay.Main.Magic
  38.  
  39. MagicSize = UDim2.new(0, 20, 0, (Magic.Value * 100)/MaxMagic.Value * -1)
  40.  
  41. MaxM = {
  42.     100, 115, 130, 150, 175,                -- Lv 1 - 5
  43.     200, 230, 265, 305, 350,                -- Lv 6 - 10
  44.     405, 465, 535, 615, 710,                -- Lv 11 - 15
  45.     815, 935, 1075, 1240, 1425              -- Lv 16 - 20
  46. }
  47.  
  48.  
  49. --< [[ Coroutines ]] >--
  50.  
  51. -- Assign Experience --
  52. coroutine.create(coroutine.resume(function()
  53.     while wait(.1) do
  54.         MaxExperience.Value = MaxE[Level.Value]
  55.         LevelDisplay.Text = Level.Value
  56.         if (Experience.Value >= MaxExperience.Value) then
  57.             Experience.Value = 0
  58.             Level.Value = Level.Value + 1
  59.         end
  60.         ExperienceBar:TweenSize(ExpSize, "In", "Sine", .1)
  61.     end
  62. end))
  63.  
  64. -- Assign Magic & Kin --
  65. coroutine.create(coroutine.resume(function()
  66.     while wait(.1) do
  67.         MaxMagic.Value = MaxM[Level.Value]
  68.         MagicRegen.Value = MaxMagic.Value / 80
  69.         if (Magic.Value < MaxMagic.Value) then
  70.             Magic.Value = Magic.Value + (MagicRegen.Value / 10)
  71.         end
  72.         MagicBar:TweenSize(MagicSize, "In", "Sine", .1)
  73.        
  74.         if Kin.Value < 1000 and Kin.Value > -1 then
  75.             KinDisplay.Text = Kin.Value
  76.         elseif Kin.Value < 1000000 and Kin.Value > 999 then
  77.             local length = string.len(tostring(Kin.Value))
  78.             KinDisplay.Text = string.sub(tostring(Kin.Value), 1, length - 3) .. "," .. string.sub(tostring(Kin.Value), length - 2)
  79.         elseif Kin.Value < 10000000 and Kin.Value > 999999 then
  80.             local length = string.len(tostring(Kin.Value))
  81.             KinDisplay.Text = string.sub(tostring(Kin.Value), 1, length - 6) .. "," .. string.sub(tostring(Kin.Value), length - 5, length - 3) .. "," .. string.sub(tostring(Kin.Value), length - 2)
  82.         elseif Kin.Value > 9999999 then
  83.             KinDisplay.Text = "E-KL-OF"
  84.         elseif Kin.Value < 0 then
  85.             KinDisplay.Text = "E-KL-UF"
  86.         end
  87.     end
  88. end))
Add Comment
Please, Sign In to add comment