Trying to return the rank name if they have the correct exp for it and Im just getting errors.

The Code:

local ranks = {}
ranks.getRank = function(experince)
local exp = tonumber(experince)
local GameRanks = require(game.ReplicatedStorage.Modules.RankList)
if exp >= tonumber(GameRanks[exp]) then
return GameRanks[exp].Rank
end
end
print(ranks.getRank("0"))
return ranks

it would make things easier if you included said errors .-.
edit: and what line the error is coming from since they might not be the same line as in the post

Either stop using tonumber or give RankList numerical keys and not strings. RankListâ€™s keys are strings but youâ€™re trying to index values in it with a number.

Here youâ€™re trying to compare exp which is a string to one of the values in the dictionary which are all tables, if you want it to find the highest rank below your exp you can loop through everything in RankList and find which one is directly under it.

local YourRankId = 0
for i, rank in pairs(GameRanks) do
if i > YourRankId and i <= exp then
YourRankId = i
end
end
local Rank = GameRanks[YourRankId]

I havenâ€™t tested this and there may be a much better method

13:30:09.535 - return GameRan:6: attempt to compare number and string

local ranks = {}
ranks.getRank = function(exp)
local GameRanks = require(game.ReplicatedStorage.Modules.RankList)
local YourRankId = 0
for i, rank in pairs(GameRanks) do
if i > YourRankId and i <= exp then
YourRankId = i
end
end
return GameRanks[YourRankId].Rank
end
print(ranks.getRank("0"))
return ranks

13:33:34.748 - local ranks = {}
13:33:34.748 - ranks.getRank = function(exp)
13:33:34.748 - local GameRanks = require(game.ReplicatedStorage.Modules.RankList)
13:33:34.749 - local exp = tonumber(exp)
13:33:34.749 - local YourRankId = 0
13:33:34.749 - for i, rank in pairs(GameRanks) do
13:33:34.749 - if i > YourRankId and i <= exp then
13:33:34.749 - YourRankId = i:7: attempt to compare number and string

local ranks = {}
ranks.getRank = function(exp)
local GameRanks = require(game.ReplicatedStorage.Modules.RankList)
local exp = tonumber(exp)
local YourRankId = 0
for i, rank in pairs(GameRanks) do
if i > YourRankId and i <= exp then
YourRankId = i
end
end
return GameRanks[YourRankId].Rank
end
print(ranks.getRank(â€ś0â€ť))
return ranks

local ranks = {}
ranks.getRank = function(exp)
local GameRanks = require(game.ReplicatedStorage.Modules.RankList)
local YourRankId = 0
for i, rank in pairs(GameRanks) do
if i > YourRankId and i <= exp then
YourRankId = i
end
end
return GameRanks[YourRankId].Rank
end
print(ranks.getRank(0))
return ranks
local module = {
[0] = {
Rank = "Private"
},
[100] = {
Rank = "Private First Class"
}
}
return module

local ranks = {}
ranks.getRank = function(exp)
local GameRanks = require(game.ReplicatedStorage.Modules.RankList)
local YourRankId = 0
for i, rank in pairs(GameRanks) do
if i > YourRankId and i <= exp then
YourRankId = i
end
end
return GameRanks[YourRankId].Rank
end
print(ranks.getRank(0))
return ranks