Yes but DarkClaw1001 wants to detect right clicking. The 'stat.useItem' criteria for items will only go up when the item is used, not necessarily when right-clicked. For example you couldn't use `stat.useItem.diamond_sword`. It would not go up when right clicked, it would only go up if you attack with it and the attack does damage. Since right clicking a carrot on a stick is 'using' it, it goes up when right clicked.
You can use an invisible, invulnerable armor stand always at the player's position and detect when the specific item is placed on the stand. Note this is not a good method though... Like I said earlier, you will lose other functionality, like left clicking, or right clicking buttons/chests/etc... Of course, you can make the armor stand only appear there while the player has the specific item in their hand, but still it isn't a perfect solution.
You could also use an invisible villager with no trades at the players position and use stat.talkedToVillager. Tag the player based on the item they are holding and run commands based on their tag and talkedToVillager score. However both the villager and ArmorStand methods come with draw backs. Most were mentioned but the biggest one I see is the fact that it won't work if the player is moving while right clicking, assuming you are teleporting the entity to the player, since there is always latency when using /tp and /teleport
With the stat.useItem.minecraft.wooden_sword scoreboard objective type, you can track when a player attacks with the sword. It might also increase when breaking blocks with them (like spider webs, leaves, or anything really.) According to the wiki, the stat will increase any time a player uses the sword in a way that should cause damage to it, regardless of unbreaking attributes.
Ok, so you want to choose a class... what you can do is use helmets, that when you right click, you put then in your head, so you can detect that..
example: You have two classes, Tank and Archer... to select, there will be two helmets in your hand, a Diamond one (renamed Tank Class) and a Gold one (renamed Archer Class). Then you will only have to detect when he puts a diamond/gold helmet. Note: to use diamond helmet in a gameplay, you will have to detect not only a type of helmet, but a renamed helmet... or a helmet with custom tag.
Rollback Post to RevisionRollBack
You know that you are lazy when you do a program to write a program
This part of the thingo is easy. I've sorted out how u pick ur class. The assassin class has a invisibility power, so I wanted the player to right click an item and then become invisible for 10 seconds or something like that