Straight to the point, I am making a reloading system for my shotgun but I want the loading of the gun's animation to loop until the players magazine is at max capacity. Here's what I got so far(keep in mind its universal so it can work with any gun I equip[this is all inside a local script placed inside StarterPlayerScripts]):

local gunsMod = require(Modules.GunsMod) --module full of all the guns info i.e. clip size, fire rate, etc. etc.

local hum = char:WaitForChild("Humanoid")

char.ChildAdded:connect(function(NewChild) --since the tool you equip becomes a child to your character it waits until something is added to the character
	if NewChild:IsA("Tool") then --checks if its a tool
		local mod = gunsMod[NewChild.Name] --gets name of whatever gun you're using
		Mouse.KeyDown:connect(function(key)
			key:lower()
			local reloadAnim = hum:LoadAnimation(NewChild.reload) --gets the shotgun the position to load
			local reloadAnim2 = hum:LoadAnimation(NewChild.reloadLoop) --loading animation
			if key == "r" then
				if not isReloading then
					if NewChild.clip.Value > 0 then --'clip' is the ammunition in reserve, 'mag' is the ammunition in the magazine.
						isReloading = true
						reloadAnim:Play()
						repeat wait() until not reloadAnim.IsPlaying
						local bulletsShot = mod.mag - NewChild.mag.Value --gets the amount of bullets you shot
						NewChild.clip.Value = NewChild.clip.Value - bulletsShot
						NewChild.mag.Value = mod.mag
						isReloading = false
					elseif NewChild.clip.Value == 0 then --if there are no more bullets in reserve when trying to reload.
						print("out of ammo!")
					end
				end
			end
		end)
	end
end)

If anyone can help that would be greatly appreciated. Thanks. :)