Advertisement
Aquarius_Raverus

Ranking System

Oct 17th, 2020
3,171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.60 KB | None | 0 0
  1. -- Ranking System
  2.  
  3. local Players = game:GetService("Players")
  4. local SS = game:GetService("ServerStorage")
  5. local Lighting = game:GetService("Lighting")
  6.  
  7. local rankReqs = script:WaitForChild("Ranks")
  8. local StatsFolder = SS:WaitForChild(".stats")
  9.  
  10. local NumToRank = {
  11.     [0] = 'F-',
  12.     [1] = 'F',
  13.     [2] = 'F+',
  14.     [3] = 'E-',
  15.     [4] = 'E',
  16.     [5] = 'E+',
  17.     [6] = 'D-',
  18.     [7] = 'D',
  19.     [8] = 'D+',
  20.     [9] = 'C-',
  21.     [10] = 'C',
  22.     [11] = 'C+',
  23.     [12] = 'B-',
  24.     [13] = 'B',
  25.     [14] = 'B+',
  26.     [15] = 'A-',
  27.     [16] = 'A',
  28.     [17] = 'A+',
  29.     [18] = 'S-',
  30.     [19] = 'S',
  31.     [20] = 'S+',
  32.     [21] = 'SS-',
  33.     [22] = 'SS',
  34.     [23] = 'SS+',
  35.     [24] = 'SS++',
  36. };
  37.  
  38.  
  39. Players.PlayerAdded:Connect(function(plr)
  40.     local plrFolder = StatsFolder:WaitForChild(plr.Name, 20)
  41.  
  42.     warn("Ranking System V.2 has loaded for ".. plr.Name.. ' | Scripted by: SenkoArdeth')
  43.  
  44.     local combatEXP = plrFolder:WaitForChild('CombatEXP')
  45.     local missionEXP = plrFolder:WaitForChild('MissionEXP')
  46.     local trainingEXP = plrFolder:WaitForChild('TrainingEXP')
  47.  
  48.     local currentRank = plrFolder:WaitForChild('Rank')
  49.     local canRank = plrFolder:WaitForChild('CanRank')
  50.     local skillPoints = plrFolder:WaitForChild('SkillPoints')
  51.    
  52.     local previousRankUp = plrFolder:WaitForChild('PreviousRankUp')
  53.  
  54.     local function checkRank()
  55.         -- No rank CD until E+ | E+ = 6
  56.  
  57.         if currentRank.Value <= 6 then -- below E+ or E+
  58.             -- below E+ or E+
  59.             canRank.Value = true
  60.  
  61.             local requirements = tostring(currentRank.Value)
  62.             requirements = rankReqs:FindFirstChild(requirements)
  63.  
  64.             if requirements then
  65.                 local totalReq = requirements.Combat.Value + requirements.Mission.Value + requirements.Training.Value
  66.                 local currentTotal = combatEXP.Value + missionEXP.Value + trainingEXP.Value
  67.  
  68.                 if currentTotal >= totalReq then
  69.                     currentRank.Value = currentRank.Value + 1
  70.                     warn(plr.Name.. " can rank up to ".. NumToRank[currentRank.Value])
  71.                    
  72.                     combatEXP.Value = 0
  73.                     missionEXP.Value = 0
  74.                     trainingEXP.Value = 0
  75.                    
  76.                     skillPoints.Value = skillPoints.Value + 1
  77.                    
  78.                 else
  79.                     warn(plr.Name.. " can not rank up to ".. NumToRank[currentRank.Value])
  80.                 end
  81.             else
  82.                 print'could not find'
  83.             end
  84.  
  85.             return;
  86.         end
  87.  
  88.         if currentRank.Value > 6 then -- above E
  89.            
  90.             warn(tick() - previousRankUp.Value)
  91.            
  92.             if tick() - previousRankUp.Value >= 600 then
  93.                 canRank.Value = true
  94.             end
  95.            
  96.             if canRank.Value == false then                             
  97.                
  98.                 print(plr.Name.. " can't rank up because his/her's CanRank value is false.")
  99.                 return;
  100.             end
  101.  
  102.             local requirements = tostring(currentRank.Value)
  103.             requirements = rankReqs:FindFirstChild(requirements)
  104.  
  105.             if requirements then
  106.                 local totalReq = requirements.Combat.Value + requirements.Mission.Value + requirements.Training.Value
  107.                 local currentTotal = combatEXP.Value + missionEXP.Value + trainingEXP.Value
  108.  
  109.                 if currentTotal >= totalReq then
  110.                     currentRank.Value = currentRank.Value + 1
  111.                     warn(plr.Name.. " can rank up to ".. NumToRank[currentRank.Value])
  112.                    
  113.                     combatEXP.Value = 0
  114.                     missionEXP.Value = 0
  115.                     trainingEXP.Value = 0
  116.                    
  117.                     canRank.Value = false
  118.                    
  119.                     previousRankUp.Value = tick()
  120.                    
  121.                     skillPoints.Value = skillPoints.Value + 1
  122.                                        
  123.                 else
  124.                     warn(plr.Name.. " can not rank up to ".. NumToRank[currentRank.Value])
  125.                 end
  126.             end
  127.  
  128.             return;
  129.         end
  130.     end
  131.  
  132.     combatEXP.Changed:Connect(function()
  133.         print'combat exp changed'
  134.         checkRank()
  135.     end)
  136.  
  137.     missionEXP.Changed:Connect(function()
  138.         print'mission exp changed'
  139.         checkRank()
  140.     end)
  141.  
  142.     trainingEXP.Changed:Connect(function()
  143.         print'trianign exp changed'
  144.         checkRank()
  145.     end)
  146. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement