How could i pick out a number from table if the number is below or above it

The title might not be as accurate as i wanted but
im trying to pick out a array from a table if a number is above or below it.

i have tried this

    Rank2 = {
        Text = "SPIRITUAL PROTECTOR",
        TextColor3 =Color3.new(170/255, 255/255, 255/255),
        TextStrokeColor3 = Color3.new(0/255, 94/255, 94/255),
        Reputation = 750000 
    },
    Rank19 = {
        Text = "ASSASSIN",
        TextColor3 =  Color3.new(166/255, 26/255, 33/255),
        TextStrokeColor3 = Color3.new(71/255, 0/255, 1/255),
        Reputation = -25000          
    },
function DisplayRanks.getRankName(Number)
    for _, Ranks in pairs(DisplayRanks.Ranks) do
        
        if (Number) < 0 then
            
            if (Number) < Ranks.Reputation then
                return Ranks
            end
        else
            if (Ranks.Reputation) > 0 then
                if (Number) > Ranks.Reputation then
                    return Ranks
                end                
            end
        end
    end
end
return DisplayRanks

I don’t quite understand what you want to happen. Could you provide an example input & output?

like i would do this

print(DisplayRank.getRankName(1000))

and it would return the rank from it

If the ranks are the following:

{
	Rank0 = {
		Reputation = 10
	},
	Rank1 = {
		Reputation = 1000
	},
	Rank2 = {
		Reputation = 2000
	}
}

Then DisplayRank.getRankName(1000)) should return Rank1?

Should DisplayRank.getRankName(1999)) also return Rank1?

yep, also if the number is a negative number like

Rank2 = {

    Reputation = -1000
},
DisplayRank.getRankName(-1000)) 

So you want it to return the rank which has the highest reputation, while still lower than the supplied number?

If that is the case, then this should work:

local ranks = {
	Rank0 = {
		Reputation = 10
	},
	Rank1 = {
		Reputation = 1000
	},
	Rank2 = {
		Reputation = 2000
	}
}

function getRank(number)
	local currentMatch = nil
	for rankName, values in pairs(ranks) do
		if values.Reputation > number then continue end -- Skip if required reputation is too high
		if not currentMatch or currentMatch.Reputation < values.Reputation then
			currentMatch = {
				Name = rankName,
				Reputation = values.Reputation
			}
		end
	end
	if not currentMatch then return end
	return currentMatch.Name
end

print(getRank(1999)) -- Rank1