Hi, I am making a game where the person with the number of kills gets awarded with cash. The catch is : I do not know how to do that.
I used table.sort() and it did not work
if i == 0 then local player = game.Players:GetPlayers() local kills= player.leaderstats.Kills.Value table.sort(plrs,kills) plrs.leaderstats.Cash.Value = plrs.leaderstats.Cash.Vaue + 25 end
I get the error saying that it expected a predicate
Note: "i" is the time
Please help me
This is not a request site but I was bored so I made a simple script that would do that.
local Best = function() local best local bestkills local Players = game:GetService("Players"):GetPlayers() for i,Player in pairs(Players) do local Kills = Player.leaderstats.Kills.Value -- Assuming that this is where the kills are stored if best then if Kills > bestkills then best = Player bestkills = Kills end else best = Player bestkills = Kills end end return best end local RewardBest = function(Amount) local best = Best() best.leaderstats.Cash.Value = best.leaderstats.Cash.Value+Amount -- Assuming that this is where cash is stored end wait(15) RewardBest(500)-- Run it whenever you want to reward the player
Note: In case that 2 players have same amount of kills it would only award one, you will have to change a few things if you want it to award both.