I’m making a game with a ton ranks, and I need some help with a script.
I want to make a for loop to go through all the ranks and see if the player has reached that rank. How could I check if their leaderstats XP is higher than Rank1 but lower than Rank2?
All the ranks are listed in a modulescript in the following format:
If your talking about the {1, 0} and {2, 50},the first number is the group rank id, and the second number is the amount of XP required to get to that rank.
I know how to do that. My question is if I am doing a for loop going through the ranks, how could get get Rank3 (the next rank) while the for loop is on Rank2?
Is there a reason why ranks aren’t set in an array? Will you be adding other info?
Otherwise this seems sufficient.
local ranks = {0, 50, 200}
for rank, amount in ipairs(ranks) do
local thisRankAmount = amount
local thisRank = rank
if not rank == #ranks then
local nextRankAmount = ranks[rank+1]
else
--Reached max rank
end
end
I originally planned on adding in the rank name, but then i realized I could just get it from the rank Id. I am also thinking about adding rank images in the future.