player detection

I wanted to make a datapack where a player could leave his body and become a ghost but I want it to be multiplayer friendly and I dont know how to detact whos body is every body
Continue to help post