Hey, I'm making a gun kit and I need to make a shotgun function. How this will work is it will do a for loop and loop the fire() function. So, it looks like this.
for count = 0, shotgunbulletCount do
fire()
end
However, because the fire() function subtracts one bullet, it will end up subtracting the value of shotgunbulletCount from the total ammo. This results in the gun running it way too quickly. Because of this, I've decided to try and subtract 1/shotgunbulletCount. What I did is I subtracted the fraction and because the for loop will loop the fire function, it should all subtract a total of 1 bullet. However, this didn't work. Please haaaalp!!!11!111!111
if not shotgun then
currentAmmo = currentAmmo - 1
else
print(currentAmmo - 1/shotgunbulletCount)
currentAmmo = currentAmmo - 1/shotgunbulletCount
end
btw it is subtracting .125..also this shotgun function is generally broken, so i will probably post more questions about it ;-;

3 comments
sorry if the explanation is bad, just ask if you have a question
The for loop will naturally iterate fire() the # of shotgunbulletCount time(s)
But the each fire() function removes 1 ammo. I need it to remove a fraction of it, so after the for loop it's subtracted 1 bullet.