Minecraft Schedule Command not working



  • I have a datapack in which a gun can be reloaded automatically when mag is emptied.

    There is a reload.mcfunction that would set the ammo value of the current player to full.

    What I want to do is, when the magazine is emptied, I schedule the reload function to reload after 4 seconds. What I did is this. schedule function namespace:gun/reload 4s However, after 4 seconds nothing happened. I am confused as to how the schedule function works in general even after checking the wiki page and I can't get the command to work even once.

    I even tried this - in a kill.mcfunction I wrote kill @s

    /execute as PlayerName run schedule function namespace:kill 1t
    

    Still, I am intact after a tick. Can someone help provide a clear syntax of the /schedule command and tell me if I did anything wrong?



  • I got it, scheduled functions are not performed by the initiator of the function scheduled, but the system is responsible. Therefore writing kill @s would not do anything for the system will not kill itself. I changed it to kill @a and the function worked.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2