Minecraft – How to make a scoreboard command that detects when a player crouches in multiplayer

minecraft-commandsminecraft-java-edition

In Minecraft 1.13/1.14, I start with some commands that work for singleplayer like:

/scoreboard objectives add Sneak minecraft.custom:minecraft.sneak_time
/execute as @a[scores={Sneak=1..}] at (my name) run effect give (my name) minecraft:jump_boost 1 2 true
/scoreboard players reset @a[scores={Sneak=1..}] Sneak

I've already tested it on a multiplayer server and it doesn't appear to work. I then tried adding a tag:

/execute as @a[name=(my name),scores={Sneak=1..}] at Dashinglizard run effect give Dashinglizard minecraft:jump_boost 1 2 true

and it still didn't work.

I do building, so I'm not very good at commands

Best Answer

It's a actually a really simple syntax mistake. Here it is the corrected version:

/execute as @a[scores={Sneak=1..}] run effect give @s minecraft:jump_boost 1 2 true

Your previous command would add the jump boost effect to you if there was anyone else, including you, crouching.

Using @s will refer to a previous entity. In this case, the @s in effect give @s refers to @a[scores={Sneak=1..}] which means it will give the effect to any, and only, player that has those specifications.

As a side note, at (your name) or at @e (or any variatons of it) will execute using this entity coordinate, thus being useless as this does not require any coordinate at all.