How can you detect if a player is falling?

I want to make a parkour map and when players fall they will be teleported back to the beginning of the parkour.
Is there a command or a set of commands to detect whether or not a player is falling?
Best Answer
This is actually not too difficult to implement by using scoreboard magic.
First, set up some scoreboard commands
scoreboard objectives add airborne dummy
scoreboard objectives add fallen dummy
Next, run the following commands on a fast clock (I suggest using a fill clock), in this order.
scoreboard players set @a airborne 0
execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:air -1 scoreboard players set @p airborne 1
scoreboard players set @a[score_airborne=0] fallen 0
scoreboard players add @a[score_airborne_min=1] fallen 1
The first two will set airborne
to 1 for every player who is not standing on something, i.e. the block beneath him is air
. The third command will reset the fallen
score to 0 for everyone who is not airborne
, the fourth increments the score 20 times a second instead. This means that fallen
is 0 as long as you were standing on something since your last fall.
Now you can select the falling players for teleportation using @a[score_fallen_min=XYZ]
. Replace XYZ
with however many seconds a player has to be above air to be considered "falling", multiplied by 20.
There is an issue with this however: Standing on the edge of a block will make you be considered falling, and I can't think of an elegant solution to this, short of chaining execute detect
commands to check a 3×3 area below the player for blocks.
Pictures about "How can you detect if a player is falling?"



How do you know if humanoid is falling on Roblox?
The FallingDown event fires when the Humanoid enters and leaves the FallingDown HumanoidStateType . The Humanoid will enter the GettingUp state 3 seconds after the FallingDown state is enabled. When this happens this event will fire with an active value of false, and Humanoid.How do you know if a player is falling in unity?
How to detect if the player is falling?How do you find falling in Minecraft?
The simple solution would be to teleport all players inside a specific area. Otherwise, you will have to deal with checking how far a player has fallen, to distinguish it from simply jumping.How do you check if a player is still touching a part?
find(part:GetTouchingParts(), v). If the table. find returns true, then the player is touching the part. That's when your part's size doesn't matter, what if the part's way too long?5 Signs a Player is Falling In Love With You
More answers regarding how can you detect if a player is falling?
Answer 2
You don't need redstone to accomplish what you are describing here. Either make the floor lava, or void, or something like that, and have the player spawn back at the beginning.
You can do it with redstone, but just having the player die upon falling off is just as effective.
Answer 3
/tp @a[x=#,y=#,z=#,r=#] X Y Z
This will teleport all players in a radius centered at an XYZ to the second XYZ. Make sure that the r (Radius of area in which players will be affected) is large enough to cover the entire bottom of your parkour, so that way it will teleport the player from the specified radius to the XYZ coordinates you put in. Loop it on a fill clock or set it to always active if you are in 1.9. however, you may want to create several areas that will teleport players if you are planning on checkpoints.
Answer 4
Perhaps fill an area with structure voids and execute a command when he player is near that block, or teleport the player when they fall below a certain height. If this doesn't work, try a testfor tag that detects downward motion.
Answer 5
Yes. You can use scoreboards, like this:
scoreboard players set @a falling 1 {Motion:[0.0,-1.0,0.0]}
Make sure you add the 'falling' objective first:
scoreboard objectives add falling dummy
Answer 6
To add on to Unionhawk just make a lava pool like he said and set the players' spawn points to the beginning of the parkour course.
Answer 7
Run tripwire hooks across the forbidden ground. Then attach a command block to them that does whatever to the player.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Kristina Paukshtite, Truman Rexti, David Morris, Kampus Production