- Script Version 2.5.3
- Script Author: YourSpeedDealer
- Minecraft Version: 1.16.5
- 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?