Solved Need Help For Simple Shooting 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!

Status
Not open for further replies.

RedDiamond

Member
Nov 30, 2020
21
0
1
23
Hei So i've made a script for shooting entity when holding an item and I wanna make it so player can't spam it, so like I want a cooldown/delay for every shoot, I hope someone understand lol
This is my current script, I want to make a delay for every fireball shoot

Code:
#Fireball Shooter
on rightclick holding a blaze rod:
  play sound "entity.blaze.shoot" with volume 1 to the player
  make the player shoot a fireball at speed 4

I hope someone could help me, I'm still new and learning about script, thx :emoji_slight_smile:
 
Well this is the first thing that comes in my mind so you could try this:
Code:
Code:
on join:
    set {Cooldown::%player%} to false
#Fireball Shooter
on rightclick holding a blaze rod:
    if {Cooldown::%player%} is false:
        play sound "entity.blaze.shoot" with volume 1 to the player
        make the player shoot a fireball at speed 4
        set {Cooldown::%player%} to true
every 3 seconds:
    loop all players:
        if {Cooldown::%loop-player%} is true:
            set {Cooldown::%loop-player%} to false
on rightclick holding a blaze rod:
    if {Cooldown::%player%} is true:
        cancel event 
        send "&cYou are on cooldown!"

Haven't tested it but it should work.
 
Please, don't use true/false, use true/not set instead. Means that if it's not true, you clear the variable. It's good for your server's performance.
 
Code:
variables:
    {Cooldown.%player%} = 0

on rightclick holding a blaze rod:
    if {Cooldown.%player%} = 0:
        set {Cooldown.%player%} to 1
        play sound "entity.blaze.shoot" with volume 1 to the player
        make the player shoot a fireball at speed 4
        wait 3 seconds
        set {Cooldown.%player%} to 0
    elseif {Cooldown.%player%} = 1:
        message "&cYou have to wait 3 seconds to shoot a fireball!" to player
this should work (not tested)
 
Status
Not open for further replies.