I'd like to add a score to the player's team when he/she right-clicks an item.but I'm having trouble adding the score to the scoreboard.What should I do? Code: public class PlayerInteract implements Listener{ @EventHandler public void onPlayerInteract(PlayerInteractEvent e){ Player p = e.getPlayer(); Material mat =p.getItemInHand().getType(); if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){ if(mat == Material.RED_ROSE){ Bukkit.broadcastMessage(ChatColor.RED + "You right clicked a rose.Plus 1!"); if(mat == Material.BLAZE_POWDER){ Bukkit.broadcastMessage(ChatColor.RED + "You right clicked a blaze powder.Plus 1!"); if(mat == Material.CROPS){ Bukkit.broadcastMessage(ChatColor.RED + "You right clicked a crop.Plus 1!"); if(mat == Material.CLAY){ Bukkit.broadcastMessage(ChatColor.RED + "You right clicked clay.Plus 1!"); if(mat == Material.FEATHER){ Bukkit.broadcastMessage(ChatColor.RED + "You right clicked a feather.Plus 1!"); if(mat == Material.RED_MUSHROOM){ Bukkit.broadcastMessage(ChatColor.RED + "You right clicked a red mushroom Plus1!"); } if(mat == Material.EMERALD){ Bukkit.broadcastMessage(ChatColor.RED + "You right clicked an emerald Plus 1!"); } } } } } } } } }
@S431 Get the player's scoreboard using player#getScoreboard() Get all the teams, loop through them, and find the one with that player in it. When you do, add +1 to the score.