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[1].leaderstats.Cash.Value = plrs[1].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.
Closed as Not Constructive by hiimgoodpack and Torren_Mr
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?