So I tried making it so that if they press r it would take 10 away from the max ammo and bring their ammo back up. But when I did the code below it infinitely added ammo and didn't stop adding at 10 it just kept going and went into the hundreds. It also took all of the max ammo.
mouse.KeyDown:connect(function(key) if key == "r" and maxammo.Value >0 then maxammo.Value = maxammo.Value - 10 repeat wait(0.1) ammo.Value = ammo.Value + 1 until ammo.Value == 10 end end)

2 comments
It brought the ammo up to 12 instead of 10 and made the maxammo 0 again, and it broke the gun.
Alright, i've edited my answer. Try that code.