How to store player names and recall them as a tag

The datapack ive been working on basically adds tags to pets to make them invincible. however, i want to give players a trigger command to list pets that they have tagged.

Continue to help post