Ranking Issues?

I have a ranking system, which is failing for unknown reason.Whenever I run this function, the rank variable is always nil. I do not understand what I am doing wrong:


local function UpdateRank()
		local Level = Player:WaitForChild("Level")
		local Rank = RankModule[tostring(Level.Value)]
		Player.Rank.Value = Rank
		game.ReplicatedStorage.PromptLevelUpNotif:FireClient(Player, Rank)
		local Character = Player.Character or Player.CharacterAdded:Wait()
		if Character then
			local Head = Character:WaitForChild("Head")
			if Head:FindFirstChild("InfoTag") then
				local Tag = Head:FindFirstChild("InfoTag")
				Tag.BC.TextHere.Text = "Level "..Player.Level.Value.." ("..Player.Rank.Value..")"
				local Tag = InfoTag:Clone()
				Tag.Parent = Head
				Tag.BC.TextHere.Text = "Level "..Player.Level.Value.." ("..Player.Rank.Value..")"

Module Content

local RankModule = {
	["1"] = "Newbie",
	["2"] = "Progressive",
	["3"] = "Ok-ish",
	["5"] = "Intermediate",
	["10"] = "Professional",
	["15"] = "Bronze Master",
	["20"] = "Silver Master",
	["30"] = "Gold Master",
	["40"] = "Diamond Master",
	["50"] = "Talented",
	["100"] = "Boundary Breaker",
	["500"] = "Sweat",
	["1000"] = "Impossible",

return RankModule

If you call the function for someone with a level not defined in your module (level 4 for example) then it would return a nil rank. Not sure if this is the case but I don’t see anything else in the code that could cause it to be nil.

1 Like

Oh damn! Yeah you are right! My implementation was wrong! Thanks for the pointer!