Here's an example of what I have set up:
rank1 = {money = 1000, Material = "Fabric", Color = BrickColor.new("Persimmon")}
The above snippet is already in a table.
But how can I return the highest value here back to a script?
This is the part I'm stuck on.
for rank,theranks in pairs(ranks) do
if theranks.RAP <= tonumber(game.Players[plrName]:WaitForChild("leaderstats").RAP.Value) then
local highest = math.max(theranks.RAP)
print(highest)
end
end
the issue I'm having is that even when using math.max it returns every value that the players is greater than, and I only want it to return the highest value there.
I'm new to module scripts but heard they're helpful.
so thanks if you can help

3 comments
Define "highest" variable before your for loop. Then print highest out after the loop is done
or do a table.sort
Thanks for helping! Messor's worked but I appreciate the contribution theking!