More ranking system issues?

For some reason, my ranking function doesn’t choose the correct rank, and it seems to be permanently stuck on:

Professional

Is there something wrong with my implementation? Or logic? I don’t know.

Help much appreciated:

Ranking Functions

		local function ReturnRank()
			for index, value in pairs(RankModule) do
				if tonumber(index) <= Level.Value then
					Rank = value
				end
			end
		end

Module

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

Thanks again!

In a table, when you set your indexes as a string, the order of implementation is going to be different than what you wrote in the script. I’ve modified your function a little bit ;

image

and it turns out the table was sorted in the following order :

image

I’d recommend using integers as index for your values in the table.

1 Like

Thanks man! I never knew it would get it all jumbled up lol

1 Like