Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get largest value's name?

Asked by 3 years ago

Hello. I have an script which gets values from an folder an writes to table and gets the largest value from table.(Script down below) But I want to get largest value’s name. Think a folder, there is values at that folder. I get the largest value, but i want to get that value’s name.

I want to use this for this:

Im trying to make an MVP system. There is an team select gui. When you click it it adds value to the folder. It renames the value to players username. When you click a button it adds +1. At the end, it compares to all values and change the text MVP players name and the value of it. Like “MVP: Uygi1234 with 52 clicks.”

My script: I only did the compare.

 local IntValueFolder = game.Workspace.clicks.players

    local valueTable = {} 

    for i, v in pairs(IntValueFolder:GetChildren()) do
        valueTable[#valueTable + 1] = {Value = v.Value} 
    end

    table.sort(valueTable, function(a, b)
        return a.Value > b.Value
    end)

    local LargestIntValue = valueTable[1].Value 
    print(LargestIntValue)

It works for get the number but as I said I want to get the name.

Thanks for reading. Uygi1234

0
You could add content in your table on line 6. .... = {Value = v.Value, Name = v.Name} Spjureeedd 385 — 3y
0
Thx Uygi1234 0 — 3y

Answer this question