Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Ranking System
- local Players = game:GetService("Players")
- local SS = game:GetService("ServerStorage")
- local Lighting = game:GetService("Lighting")
- local rankReqs = script:WaitForChild("Ranks")
- local StatsFolder = SS:WaitForChild(".stats")
- local NumToRank = {
- [0] = 'F-',
- [1] = 'F',
- [2] = 'F+',
- [3] = 'E-',
- [4] = 'E',
- [5] = 'E+',
- [6] = 'D-',
- [7] = 'D',
- [8] = 'D+',
- [9] = 'C-',
- [10] = 'C',
- [11] = 'C+',
- [12] = 'B-',
- [13] = 'B',
- [14] = 'B+',
- [15] = 'A-',
- [16] = 'A',
- [17] = 'A+',
- [18] = 'S-',
- [19] = 'S',
- [20] = 'S+',
- [21] = 'SS-',
- [22] = 'SS',
- [23] = 'SS+',
- [24] = 'SS++',
- };
- Players.PlayerAdded:Connect(function(plr)
- local plrFolder = StatsFolder:WaitForChild(plr.Name, 20)
- warn("Ranking System V.2 has loaded for ".. plr.Name.. ' | Scripted by: SenkoArdeth')
- local combatEXP = plrFolder:WaitForChild('CombatEXP')
- local missionEXP = plrFolder:WaitForChild('MissionEXP')
- local trainingEXP = plrFolder:WaitForChild('TrainingEXP')
- local currentRank = plrFolder:WaitForChild('Rank')
- local canRank = plrFolder:WaitForChild('CanRank')
- local skillPoints = plrFolder:WaitForChild('SkillPoints')
- local previousRankUp = plrFolder:WaitForChild('PreviousRankUp')
- local function checkRank()
- -- No rank CD until E+ | E+ = 6
- if currentRank.Value <= 6 then -- below E+ or E+
- -- below E+ or E+
- canRank.Value = true
- local requirements = tostring(currentRank.Value)
- requirements = rankReqs:FindFirstChild(requirements)
- if requirements then
- local totalReq = requirements.Combat.Value + requirements.Mission.Value + requirements.Training.Value
- local currentTotal = combatEXP.Value + missionEXP.Value + trainingEXP.Value
- if currentTotal >= totalReq then
- currentRank.Value = currentRank.Value + 1
- warn(plr.Name.. " can rank up to ".. NumToRank[currentRank.Value])
- combatEXP.Value = 0
- missionEXP.Value = 0
- trainingEXP.Value = 0
- skillPoints.Value = skillPoints.Value + 1
- else
- warn(plr.Name.. " can not rank up to ".. NumToRank[currentRank.Value])
- end
- else
- print'could not find'
- end
- return;
- end
- if currentRank.Value > 6 then -- above E
- warn(tick() - previousRankUp.Value)
- if tick() - previousRankUp.Value >= 600 then
- canRank.Value = true
- end
- if canRank.Value == false then
- print(plr.Name.. " can't rank up because his/her's CanRank value is false.")
- return;
- end
- local requirements = tostring(currentRank.Value)
- requirements = rankReqs:FindFirstChild(requirements)
- if requirements then
- local totalReq = requirements.Combat.Value + requirements.Mission.Value + requirements.Training.Value
- local currentTotal = combatEXP.Value + missionEXP.Value + trainingEXP.Value
- if currentTotal >= totalReq then
- currentRank.Value = currentRank.Value + 1
- warn(plr.Name.. " can rank up to ".. NumToRank[currentRank.Value])
- combatEXP.Value = 0
- missionEXP.Value = 0
- trainingEXP.Value = 0
- canRank.Value = false
- previousRankUp.Value = tick()
- skillPoints.Value = skillPoints.Value + 1
- else
- warn(plr.Name.. " can not rank up to ".. NumToRank[currentRank.Value])
- end
- end
- return;
- end
- end
- combatEXP.Changed:Connect(function()
- print'combat exp changed'
- checkRank()
- end)
- missionEXP.Changed:Connect(function()
- print'mission exp changed'
- checkRank()
- end)
- trainingEXP.Changed:Connect(function()
- print'trianign exp changed'
- checkRank()
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement