Code | // Defining local variables for later use
local BestScore = 0
local BestPlayer
// Looping trough a table of all players where v is an individual player.
for k,v in pairs( player.GetAll() ) do
local Frags = v:Frags() // Getting a player's frags
if Frags > BestScore then // If it's higher then the current BestScore then
BestScore = Frags // Make it the new BestScore
BestPlayer = v:Name() // And make the player the new BestPlayer
end
end
if BestScore != 0 then // If anyone had a score higher then 0 then print the results.
print("The best player is " .. BestPlayer .. " with a score of " .. tostring(BestScore) .. "!")
end |