tag @s add donation_temp
execute as @a[gamemode=!spectator,distance=..250] unless score @s ctf_ID = @n[tag=donation_temp] ctf_ID run tag @s add donation_pool

execute as @a[tag=donation_pool,sort=random,limit=1] run tag @s add donation_target

tag @a[tag=donation_pool] remove donation_pool

tellraw @a[distance=..250] ["",{"text":"HOW GENEROUS!","bold":true,"color":"green"},{"text":"\n"},{"selector":"@s","color":"white"},{"text":" decided to donate","color":"aqua"},{"text":" 50 coins","color":"gold"},{"text":" to","color":"aqua"},{"text":" ","color":"white"},{"selector":"@n[tag=donation_target]","color":"white"},{"text":"!","color":"aqua"}]

function pctf:logic/player/coins/remove {amount: "50"}
execute as @n[tag=donation_target] run function pctf:logic/player/coins/set_coins_to_add {amount: "50"}

tag @n[tag=donation_target] remove donation_target

tag @s remove donation_temp