I have made a gun that works perfectly fine except the reload part. The problem is that if i have less then 12 of my spareammo and less then 12 ammo in the clip, then if i reload i will get 0 ammo and 0 in spareammo or even less sometimes i got -6 spareammo?
function reload(key)
key:lower()
if key == "r" and spareammo >= 1 and not reloading and Ammo <= 11 then
game.Players.LocalPlayer.PlayerGui.weapongui.ReloadingLabel.Visible = true
print("Reloading")
reloading = true
IsFiring = false
wait(Reloadtime)
reloading = false
--Ammo is set to the value 12 and spareammo is 30 from the start
spareammo = spareammo + (Ammo - 12)
if spareammo >= 12 then
Ammo = 12
elseif spareammo <= 11 and spareammo > 0 then
Ammo = spareammo
elseif spareammo == 0 then
Ammo = 0
end
game.Players.LocalPlayer.PlayerGui.weapongui.ReloadingLabel.Visible = false
end
end
mouse.KeyDown:connect(reload)
Gun.Deactivated:connect(stopshooting)
Gun.Activated:connect(shoot)
if you dont understand the problem then i can try to explain it better for you.

1 comment
Thanks it works