Table.sort loves only one human

Well I just made script the reward for only winner.

I searched and made like almost 100% in here -

(Player with the most score system - #10 by TheBigC10)

As you see, this table.sort script gives 1st player 10000 cash(falud).

-added for more information

That 1st player is someone has most “fulad”.
Yes this script find whoever has most “fulad”, and give the winner 10000 cash(falud) in addition.

And “musgara” is… just a value for timing of script working

this script actually loves only one human and it must work like it.

But the problem is…

It sooooooooooo loves one human only.

It means When 2+ humans there, It does not work.

yesaaa…
I dont know about table script, so I so need your help…
I think this is last problem of beta version of mine(please)

Pls help me to release my second game!!!

I’m a bit confused. Are you trying to give cash to only the players that won? Do you only want to give cash to one winner?

You’re doing local winner = players_list[1] which is only referencing one player in the players_list table that you sorted.

Also you should probably explain what your variable names represent. What is “fulad” and “musgara”, kind of hard to tell what it is your doing when you have very unique variable names.

Musgara is = “Live”
Fulad is = “Full”

It’s Zulu which I’ve never heard of but yeah, I would be able to help a bit more but Im not home, figured I’d help him with translation.

Also I don’t suggestion running loops, used a changed event on a bool value or something whenever the game ends.

1st player, this script is for only one guy.

SIKINBAUR

musgara is value that changed following the time. as you see, musgara changed to 2 at 25 ~ 28 sec.
when it is 2, the reward script worked.
And fulad is just money. In my first video, the leaderboard ‘Fallar’ increased as much 10000.

So sorry to make you confused not to give more information

I cant solve this myself because I dont know table.sort script…
Somebody helppp :joy:

table.sort takes an array-like table

local array : {[number]: any} = {0, 4, 1, 5, 2, 6, 3}

table.sort(array, function (a: number, b: number)
       if a > b then return true else return false end
end)

print(array) --: output - {6, 5, 4, 3, 2, 1} (intended) not sure if i typed it right.

Should I attach the value which is the standard of choosing winner in “any” at line 1?
and those numbers {0, 4, 1, 5, 2, 6, 3} mean what?

If the information is scarce I say again,
I want to make the script that choose winner who has most value of fulad

dam if I attached the informations well at first I dont have to written this…

it sorts based on a being more than b, return true a will come before b in the new / mutated table, but it does this across all values

if you want the person with the most,
you can always do

local array = {
{game.Players.Player, 100},
{game.Players.Player2, 50}
} -- array of value associated with player

table.sort(array, function(a: table, b:table)
    if a[2] > b[2] then
        return true
    end
    return false
end)

a | b [1] = player
a | b [2] = value
from there you can index [1] in the array, returning a table with index [1] being player, and index [2] being the value in question.
further more you can use that to do what you need.

1 Like

What also those numbers in line 2 100, 50 mean?
and what the a, b in line 6 mean?

I did it in studio but it has error in 2 line.

cras

asas

I dont know table script But, I also searched writings and videos about table script but cant understand it…

1 Like