Solved (Help) Right Click Event runs twice when clicking on an entity

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

Nutrition35

Member
Feb 11, 2020
11
0
1
19
  1. Script Version 2.5.3
  2. Script Author: YourSpeedDealer
  3. Minecraft Version: 1.16.5
  4. Full Code:
Code:
on right click:
    if name of player's tool contains "&bM4A1":
        if {gun::reloading::%player%} is true:
            stop
        if {kyle::%player%} is not true:
            set {_ammunition} to getItemTag(player's tool, "ammunition")
            if {_ammunition} is "ammunition":
                set player's tool to setItemTag(player's tool, "ammunition", 30)
                set {_ammunition} to getItemTag(player's tool, "ammunition")
            if {_ammunition} is more than 0:
                send action bar "&c%{_ammunition}% &8/ &a31" to player
                shoot an egg from player's head at speed 4.5
                set {bulletegg.%shooter%} to 1
                play sound "entity.generic.explode" from master category at volume 0.35 with pitch 2 at player's location
                set player's tool to setItemTag(player's tool, "ammunition", {_ammunition}-1)
            else:
                send action bar "&cOUT OF AMMUNITION" to player
                play sound "BLOCK_DISPENSER_DISPENSE" at volume 0.35 with pitch 2 at player's location

No errors.

When I'm right clicking my gun at a distance from any given entity, my gun only minuses 1 away from {_ammunition}. However, if i'm within hitting range of the entity and looking at it, essentially right clicking the entity, the right click event plays twice and I lose 2 ammo per right click, making the gun run out of ammo faster. my question being, when I right click and if I am in range of an entity, how do I only make it do the right click event once?
 
Status
Not open for further replies.