so okey i have made a gun that works but when i reload i can spam the reload key and its annoying cuz if you ever happend to click it twice youre ammo decreases alot.
function reload(key)
key:lower()
local reloading = false
if key == "r" and Ammo < 30 and not reloading then
reloading = true
Ammo = 0
game.Players.LocalPlayer.PlayerGui.weapongui.ReloadingLabel.Visible = true
spareammo = spareammo + (Ammo - 30)
print("Reloading")
wait(Reloadtime)
print(spareammo)
if spareammo > 29 then
Ammo = 30
elseif spareammo < 30 and spareammo > 0 then
Ammo = spareammo
elseif spareammo == 0 then
Ammo = 0
end
game.Players.LocalPlayer.PlayerGui.weapongui.ReloadingLabel.Visible = false
reloading = false
end
end
mouse.KeyDown:connect(reload)

2 comments
Try making reloading a global function and using "reloading == false" instead of "not reloading"
@FearMeIAmLag "not reloading" is pretty much the same as "reloading == false" in this context.