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 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
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.
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.