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)
mouse.KeyDown:connect(function(key) if key:lower() == "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)
This might fix it, but I'm not sure.
EDIT
Try this:
mouse.KeyDown:connect(function(key) if key:lower() == "r" and maxammo.Value >0 then while ammo.Value<10 do ammo.Value = ammo.Value + 1 maxammo.Value=maxammo.Value-1 wait(0.1) end end end)