This is one of the cases where using stat
objectives on a scoreboard comes in handy, since it is impossible to detect players who don't have a score (i.e. a score of NULL, which is different from a score of 0!). stat
objectives increase automatically depending on player actions, making them ideal for this. Set up a timePlayed
objective like this:
/scoreboard objectives add timePlayed stat.playOneMinute
Contrary to the name, playOneMinute
objectives increase at every game tick (making the value 1200 after one minute). You can use this objective to detect new players using @a[score_timePlayed=1]
.
To teleport new Players to a fixed point, set up a setblock clock and have it run
/tp @a[score_timePlayed=1] x y z
where x y z
are the coordinates of your spawn.
Credit goes to /u/Boxfigs on reddit.
Should you want to re-declare an existing player as new (e.g. for testing), you can use
scoreboard players reset P timePlayed
where P
is any valid target selector.