How can I teleport only certain people in Minecraft



  • I want to make a teleport command with command blocks that allows only people with certain names to teleport. So basicly its an admin only button and if your name isnt on one of the command blocks you cant teleport, it would also check if the player was in a radius of two blocks. What I have tried is /tp [r=2] and /tp @p[name=,r=2] and neither have worked. Is this possible?

    edit: The problem I'm having after further experimenting with the same code is when I use the to teleport it grabs the right person but it teleports them from anywhere no matter the person who steps on it because the radius doesn't seem to work. and with the other code that uses the @p variable it has the radius right but I can set the name property to no one on the server and it still teleports the closest person (it seems to teleport the closest person if it cant find the name, when I want it to teleport nothing if the name is not found). Maybe I need to add some redstone but I don't know if that would help.



  • If you only want to teleport people who are in a certain group, you can use the new scoreboard command to create a 'group' of people (using teams), and then teleport only that team with this command (targets nearest player in the group specified)

    /tp @p[team=,]   
    

    To set up your groups, you can create a group like this:

    /scoreboard teams add  
    

    And then add people to this group like this:

    /scoreboard teams join  
    

    The advantage of this system is also that you can use it actually to separate groups in the actual game. The scoreboard command has a feature that means that the display name of a team will be displayed before the actual username, appearing like this in the chat:

    [] : ...
    

    More info on this system can be found in the wiki page linked above.


    Changing the @p in the first command above to a player name will stop it from working, because parameters that are inside the [ and ] will only work for @p, @a, and @r. So you cannot substitute the first command above to /tp [r=2] . It just won't work.
    If you really want to use the r parameter on a single person, try using the above method that uses teams, but only put one person in the team. Here is a quick way to do this. Type these into the command console:

    /scoreboard teams add  
    /scoreboard teams join  
    

    And then in the command block, to teleport that person if they are in a radius of 2, you could use:

    /tp @p[team=,r=2]   
    

    Alternatively, you could just specify the name of the player in the selector. Following the previous example, if you want to teleport a certain person if they are in a radius of 2, you could use:

    /tp @p[name=,r=2]   
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2