local function c(c)if not reloading and(currentAmmo<clipSize and tool.Equipped)then tool.Handle.ReloadSound:Play()reloading=true canFire=false if infiniteAmmo then shotEvent:FireClient(c,"--",clipSize)wait(reloadTime)currentAmmo=clipSize shotEvent:FireClient(c,currentAmmo,clipSize)elseif consolidateAmmo then remainingAmmo=currentAmmo shotEvent:FireClient(c,"--",ammoLeft)wait(reloadTime)currentAmmo=math.min(clipSize,ammoLeft+remainingAmmo)ammoLeft=(ammoLeft+remainingAmmo)-math.min(clipSize,ammoLeft+remainingAmmo)shotEvent:FireClient(c,currentAmmo,ammoLeft)else shotEvent:FireClient(c,"--",ammoLeft)wait(reloadTime)currentAmmo=math.min(clipSize,ammoLeft)ammoLeft=ammoLeft-math.min(clipSize,ammoLeft)shotEvent:FireClient(c,currentAmmo,ammoLeft)end canFire=true reloading=false end end
-- Function to bind to reload event
local function reload(player)
	if not reloading and currentAmmo < clipSize and tool.Equipped then
		tool.Handle.ReloadSound:Play()
		reloading = true
		canFire = false
		if infiniteAmmo then -- dealing with infinite ammo
			shotEvent:FireClient(player, "--", clipSize)
			wait(reloadTime)
			currentAmmo = clipSize
			shotEvent:FireClient(player, currentAmmo, clipSize)
		elseif consolidateAmmo then -- dealing with limited ammo that saves what's in your current clip
			remainingAmmo = currentAmmo
			shotEvent:FireClient(player, "--", ammoLeft)
			wait(reloadTime)
			currentAmmo = math.min(clipSize, (ammoLeft + remainingAmmo))
			ammoLeft = (ammoLeft + remainingAmmo) - math.min(clipSize, (ammoLeft + remainingAmmo))
			shotEvent:FireClient(player, currentAmmo, ammoLeft)
		else -- dealing with limited ammo where you throw away any ammo remaining in your clip when you reload
			shotEvent:FireClient(player, "--", ammoLeft)
			wait(reloadTime)
			currentAmmo = math.min(clipSize, ammoLeft)
			ammoLeft = ammoLeft - math.min(clipSize, ammoLeft)
			shotEvent:FireClient(player, currentAmmo, ammoLeft)
		end
		canFire = true
		reloading = false
	end
end
