I have the following script in my game, a module script stored in ReplicatedStorage:
local rank = {}
local BadgeService = game:GetService("BadgeService")
local ranks = { --- ranks and their associated levels
["President"] = {lvl=120, badge=2124579788, abbreviation = "PRES"},
["Commander"] = {lvl=110, badge=2124512184, abbreviation = "COM"},
["General"] = {lvl=100, badge=2124509861, abbreviation = "GEN"},
["Colonel"] = {lvl=90, badge=2124509860, abbreviation = "COL"},
["Major"] = {lvl=80, badge=2124509859, abbreviation = "MAJ"},
["Captain"] = {lvl=70, badge=2124509858, abbreviation = "CPT"},
["Lieutenant"] = {lvl=60, badge=2124509857, abbreviation = "LT"},
["Staff Sergeant"] = {lvl=50, badge=2125772356, abbreviation = "SSGT"},
["Sergeant"] = {lvl=40, badge=2124509856, abbreviation = "SGT"},
["Corporal"] = {lvl=30, badge=2124509854, abbreviation = "CPL"},
["Specialist"] = {lvl=20, badge=2125772350, abbreviation = "SPC"},
["Private First Class"] = {lvl=10, badge=2124509853, abbreviation = "PFC"},
["Private"] = {lvl=1, badge=198196955, abbreviation = "PVT"},
}
function rank.Check(player,level) --- this sees what rank someone is. We use it for the GUI
local stats = player:WaitForChild("leaderstats")
local levels = stats:WaitForChild("Level")
level = levels.Value
for rak,tabl in pairs(ranks) do
if level >= tabl.lvl then
print(player.Name.." is a "..rak.." at level "..level)
return rak
end
end
end
I have this in ReplicatedStorage so the GUIs and serverscripts can call it to display a player’s rank both in said GUIs and their chat tag that other players see.
The issue is, this script seems to cap out at “Captain” and won’t display the correct rank for people level 80 and over:
https://gyazo.com/634ebcdd3822e72c5f3ee7163b5d6863
As you can see, I’m a level 109 yet it still says I’m a Captain when I should be a General.
Why is it doing this?