Solved Projectiles rate too fast

  • 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.

IDuckz_

Active Member
Jul 25, 2019
106
2
18
19
I am stuck with this bug, so I am making a guns script, everything is working fine, but I made an automatic gun and it just fires too quickly that some projectiles sometimes doesn't damage the entity (mob, animals, or players).

Here is my code:

Code:
command /gun:
 permission: command.gun
 permission message: no
 trigger:
  set {autoGun} to iron ingot named "&aAuto gun"
  give {autoGun} to player

on rightclick:
    if player is holding {autoGun}:
        if {autoGun::%player's uuid%} is set:
            if now > {autoGun::%player's uuid%}:
                shoot a snowball from the player at speed 2.75
                set {autoGun::%player's uuid%} to 0.1 seconds from now
            stop
        shoot a snowball from the player at speed 2.75
        set {autoGun::%player's uuid%} to 0.1 seconds from now

on damage:
 if attacker is holding {autoGun}:
  if attacker is a player:
   if projectile is a snowball:
    damage victim by 0.5 hearts
    stop

Skript Version: 2.2dev36

Skript Addons: SkQuery, SkRayFall, Skellet, TuSKe, SkNBeeT, Sk-Perm, and SkDragon

I hope someone can find a solution to this issue, thanks.
 
Can't you just add a delay to the end of skript? Like this
Code:
command /gun:
 permission: command.gun
 permission message: no
 trigger:
  set {autoGun} to iron ingot named "&aAuto gun"
  give {autoGun} to player
 
on rightclick:
    if player is holding {autoGun}:
        if {autoGun::%player's uuid%} is set:
            if now > {autoGun::%player's uuid%}:
                shoot a snowball from the player at speed 2.75
                set {autoGun::%player's uuid%} to 0.1 seconds from now
                wait 1 second
            stop
        shoot a snowball from the player at speed 2.75
        set {autoGun::%player's uuid%} to 0.1 seconds from now
        wait 1 second
 
on damage:
 if attacker is holding {autoGun}:
  if attacker is a player:
   if projectile is a snowball:
    damage victim by 0.5 hearts
    stop
You can also decrease the speed of the snowball to make it slower and give the skript a bit of time to think
 
Didn't work, still the same, and its not about skript, its about minecraft I think, the projectiles shoot fine but whenever it hits the mob, you have to wait for the mob to be damaged then it'll damage the mob again.
 
So yeah, just add a delay that is long enough to give Minecraft enough time to damage the mob for each individual hit
 
Uh how?

Edit: Nevermind, I got it working, thanks for telling me about the delay part, it worked :emoji_slight_smile:
 
Last edited:
Status
Not open for further replies.