Hello, I am making a deathmatch mode in my game, and of course, kills will be a number. If I put them in an array, is there a command in whch I can find the greatest value? Thanks, ~Yoman1776
Hmm, normally I wouldn't a question like this, since you haven't shown any effort. However, the script is simple:
I recommend writing a generic for loop that iterates through the table (goes through it), and compares all of the values to each other, returning the largest one. I'm not sure if there's a simple way, but this is my way: (I didn't test this since I'm not home, but it should work)
local My_Table = {1,7,4,30,5} function FindGreatestValue() local greatest = 0 for _,v in pairs(My_Table) do if (tonumber(v) > tonumber(greatest)) then -- Tonumber isn't needed, but in some cases it is greatest = tonumber(v) end end return greatest end print(FindGreatestValue()) -- Will print what it returns, which would be 30