I want to add a cooldown to this script

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Rentier

Member
Jul 11, 2024
3
0
1
24
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
 
havent tested
AppleScript:
on rightclick:
    player is holding a netherite sword
    if difference between now and metadata tag "COOLDOWN" of player is less than 30 seconds:
        message "&fWait %round(difference between now and metadata tag "COOLDOWN" of player)% seconds before use again!" to player
    else:
        damage the targeted entity by 5 hearts
        loop 40 times:
            set {_location} to location of the targeted entity
            set {_location} to {_location} ~ vector(random number between 2 and -2, random number between 2 and -2, random number between 2 and -2)
            play red colored dust at {_location} to the player
        play redstone block breaking at targeted entity's location to the player
        set metadata tag "COOLDOWN" of player to now
 
havent tested
AppleScript:
on rightclick:
    player is holding a netherite sword
    if difference between now and metadata tag "COOLDOWN" of player is less than 30 seconds:
        message "&fWait %round(difference between now and metadata tag "COOLDOWN" of player)% seconds before use again!" to player
    else:
        damage the targeted entity by 5 hearts
        loop 40 times:
            set {_location} to location of the targeted entity
            set {_location} to {_location} ~ vector(random number between 2 and -2, random number between 2 and -2, random number between 2 and -2)
            play red colored dust at {_location} to the player
        play redstone block breaking at targeted entity's location to the player
        set metadata tag "COOLDOWN" of player to now
doesnt work, but i dont get an error is just doesnt do anything when i rightclick
 
so neither your script (or my script) work now, i cant figure out what changed didnt change anything in the server or changed any plugins