So im currently working on a script and i want to add a 30s cooldown to the items ability. I use a netherite sword and if you right click it, it deals 5 hearts of damage to the targeted entity. Heres the code:
on rightclick:
if player is holding a netherite sword:
damage the targeted entity by 5 hearts
loop 40 times:
set {_location} to location of the targeted entity
add random number between -2 and 2 to x-coord of {_location}
add random number between -2 and 2 to y-coord of {_location}
add random number between -2 and 2 to z-coord of {_location}
play red colored dust at {_location} to the player
play redstone block breaking at {_location} to the player
on rightclick:
if player is holding a netherite sword:
damage the targeted entity by 5 hearts
loop 40 times:
set {_location} to location of the targeted entity
add random number between -2 and 2 to x-coord of {_location}
add random number between -2 and 2 to y-coord of {_location}
add random number between -2 and 2 to z-coord of {_location}
play red colored dust at {_location} to the player
play redstone block breaking at {_location} to the player