execute store result storage pctf:map input.map_id int 1 run scoreboard players get @s map_id

particle minecraft:poof ~ ~ ~ 0 0 0 0.25 100
playsound minecraft:entity.item.pickup player @a ~ ~ ~ 2 0

execute if entity @s[tag=light_purple_flag] run tellraw @a[distance=..250] ["",{"text":"The "},{"text":"Magenta Flag","color":"light_purple"},{"text":" has been returned!"}]
execute if entity @s[tag=aqua_flag] run tellraw @a[distance=..250] ["",{"text":"The "},{"text":"Aqua Flag","color":"aqua"},{"text":" has been returned!"}]
execute if entity @s[tag=yellow_flag] run tellraw @a[distance=..250] ["",{"text":"The "},{"text":"Yellow Flag","color":"yellow"},{"text":" has been returned!"}]
execute if entity @s[tag=green_flag] run tellraw @a[distance=..250] ["",{"text":"The "},{"text":"Green Flag","color":"green"},{"text":" has been returned!"}]

execute if entity @s[tag=light_purple_flag] run function pctf:create_game_object/flag/light_purple with storage pctf:map input
execute if entity @s[tag=aqua_flag] run function pctf:create_game_object/flag/aqua with storage pctf:map input
execute if entity @s[tag=yellow_flag] run function pctf:create_game_object/flag/yellow with storage pctf:map input
execute if entity @s[tag=green_flag] run function pctf:create_game_object/flag/green with storage pctf:map input