How to save a players nbt for later

I am coding a datapack for an event, in the event there are four corners that try to battle it out, but sometimes they all pick out a player to battle in a minigame for som extra perk. My idea was to teleport the contestants to a custom dimension(I got that wotking) but i also want to save the players inventory and positions så they can go back to where they were before the minigame. The most important thing to get working is the inventory since i want to have a build battle minigame where they get creative mode so i cant let them walk out of the minigame with any item they would want. And I also want them to have an empty inventory beforehand so they wont have an advantage in anything.

Continue to help post