In my game, I have ranks that require a certain amount of XP to reach. How can I figure out what rank the player on join by comparing their XP saved in a datastore to the XP required for each rank?
local rankXpRequirements = {0, 50, 200}
function findEligibleRank(player)
for rank, xpReq in rankXpRequirements do
if xpReq > player.Xp then
return rank - 1 --Req too high, so the highest eligible rank is the previous one
end
end
return #rankXpRequirements --Max rank
end