The answers you are looking for can be found on the Minecraft Wiki entries for scoreboard and commands.
Setting up teams
To assign a player to a team you have to set up the teams first, using
/scoreboard teams add <team> [display name]
/scoreboard teams option <team> color <value>
<team>
is the name of the team, e.g. red
or blue
. [display name]
is an optional longer name, used in the scoreboard display, e.g. Team Ocelot
or Team Jacob
. The second command sets the team color, use [tab] after color
to see your options, e.g. red
, blue
.
The command to assign someone to a team is
/scoreboard teams join <team> [players]
I suggest using simple pressure plates at the cave entrances, with the command blocks right below. You can then use @p
fpr [players]
to select the nearest player, who is normally the one that triggered the plate. Alternatively, you can use @a[r=X]
to assign everyone in an X
block radius sphere around the command block at once, or specify a block range with the selectors x
, y
, z
, dx
, dy
and dz
.
Teleport by team
To teleport every player on a specific team, you can use the @a
selector with the team
specifier, i.e.
/tp @a[team=<team>] <x> <y> <z>
You can find out how the /testforblocks command works here. The syntax is exactly the same as the /clone command. Basically, the first two sets of coordinates specify the two corners of the first cuboid region you want to test, and the third set of coordinates specifies the lower northwestern corner of the cuboid region you want to test your first region to. Both regions will be the same size. In more recent versions of Java Edition Minecraft you can tell which corner of your structure is the lower northwestern corner by hitting F3 and looking at the axes in the center of your screen; whichever corner or your region fits into those axes is the lower northwestern corner of that region. This same trick applies to the /clone command.
In 1.13+, the /testforblocks command was moved into the /execute command to make it easier to compare regions and due something accordingly in the same command. Instead of using the command
/testforblocks 0 0 0 5 10 5 20 10 20
you can use
/execute if blocks 0 0 0 5 10 5 20 10 20
and modify the command to fit what you want. You can read more about the /execute command here.
I'm aware that this post is 3 years old, but this seems like an important question to answer as the syntax of the /clone and /testforblocks commands are very confusing.
Best Answer
You can use the
/playsound
command as follows:The volume, pitch and player are optional
A list of sounds can be found here in the sound event column.