I want to make it so that i have a command block that tests for if a player has a glass bottle selected in slot 1 of their hotbar, if this is true, that specific player and only that player is added to a team. Any player that is in that team gets a temporary invisibilty potion effect for 30 seconds and then it replaces the glass bottle in the persons hotbar with a water bottle and removes them from the team. The reason i want to do this is i want to make a temporary, rechargeable power up that a player can activate so that they use an item, get an ability, after a certain amount of time lose the ability and get the original item back after the "power" has recharged.
The problem i have is... I can test if a player has a specific item in a specific slot sure, and then have a comparator come out of the command block that gets an output if the testfor command becomes true for any player. But then i dont know how to only target that specific player with the glass bottle to be put into a team since the only targeting commands are @a, @p, or @r. These targeting commands dont work since i dont want all players to be added to the team and get the potion effects and i dont want the player closest to the command block get added to the team and get the potion effects as the player that activated the testfor command block may be further away from the command block than another person. And ofcourse, a random player wouldnt work either. So is there a command where i can target all players that have a glass bottle in slot 1 of their hotbar and add them to a team rather than seeing if a player has a glass bottle in slot 1 of their hotbar and adding all people to a team.
Sorry for the long explanation, im not very good at explaining things, if anyone can help, that would be greatly appreciated.