How do i get the loswer number?

hello. I was wondering how can i get the lowest Number of some numbers.
in my case i’m using magnitude and i want to check who’s the nearest player to an object.
thanks :slight_smile:

Solution A

minimum = math.min(unpack({3, 5, 7, 1})) --1
minimum = math.min(3, 5, 7, 1) --1

Solution B

local function min(numbers)
    if #numbers == 0 then return nil end
    local minimum = numbers[1]
    for i, number in ipairs(numbers) do
        if number < minimum then
            minimum = number
        end
    end
    return minimum
end
minimum = min({3, 5, 7, 1}) --1

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.