## loop.mcfunction

#Determine highest score holder
scoreboard players set #highest rank.temp 0
scoreboard players operation #highest rank.temp > @a[tag=checking_flags,scores={rank.temp=0..}] rank.temp

#Protection for multiple people having the same score + Assigning them their rank
scoreboard players set #ranked rank.temp 0
execute as @a[tag=checking_flags] if score @s rank.temp = #highest rank.temp run function pctf:logic/game/end/end_stats/stolen_flags/rank


#If there are still people with a score on the temporary scoreboard, run again
execute if entity @a[tag=checking_flags,scores={rank.temp=0..}] run function pctf:logic/game/end/end_stats/stolen_flags/loop