Minecraft – playsound command for a jetpack

minecraft-commandsminecraft-java-edition

I am making a Minecraft jetpack with a testfor command a /execute command which gives me levitation and also with particle effects. I am trying to add sound with the playsound command by putting it on top of the chain command blocks for the /execute and the particles but it makes this really horrible sound because it is playing constantly. I tried to put it in a separate repeating command block but it doesn't work. Does anyone know how to do this? Thanks!

Best Answer

You probably want to loop the command slower. You can do this using redstone (just a regular redstone clock).

If you don't want to use redstone, you can tell the command block to only execute the command every few iterations.
To do this, you assign a timer scoreboard to the player that ticks up every game tick and only if it reaches the time you want, the sound gets played and then the timer gets reset.

Setup:

scoreboard objectives add timer dummy

In loop, replace @p with the selector of the flying player and ... with the rest of your playsound command:

scoreboard players add @p timer 1
playsound @p[scores={timer=20}] <...>
scoreboard players set @p[scores={timer=20}] timer 0

If it's a function, you can also use /schedule (archive):

/schedule function <function> 20

or:

/schedule function <function> 1s