Minecraft – Using Minecraft command blocks to automatically TP players when they join

minecraft-commandsminecraft-java-edition

I am trying to make a Hunger Games map on MC 1.5.2 and I am almost finished. I have most of the command blocks set ready for the games but for some reason, everyone keeps spawning on top the glass sphere and not in the lobby I made. Even after I changed the spawnpoint and did /kill, I still spawned on top of the sphere so to counteract that, I made a TP command block which TPs all people to the lobby. Though what I want is something that can TP each person to the lobby when they join, automatically, so that they don't spawn on top the sphere without them being able to get to the lobby and having me to manually press the TP all to lobby button.

So, any suggestions on how I can make an Auto-TP when people join my server?

Best Answer

There are several ways to solve your problem. One is the /gamerule spawnRadius 0 command, which will change the spawn point so it is only on one block. Then do /setworldspawn where you want people to spawn in. Keep in mind, if you've ever done /spawnpoint in your world, it will override the /setworldspawn command, so you might want to test it out with a player other than yourself. Another way is what you said to do. You can place a repeating command block that runs the command /testfor @a[x y z r] where x,y,z are the coordanates of the place where the players spawn in incorrectly, and r is the radius of those coordanates where the players spawn incorrecly. Keep in mind that the [] are necessary in that command, and there is no space in between @a and [] You will need to put a redstone comparator coming out of this command block, and head ing to one that says /tp @a[x y z r]x y z where the first xyzr are the same as before, and the second set are the coordanates of the world spawnpoint.