How to prevent 2x while loop for timers

Sup!

So i wanna make a sprinting script for my and my friends game.

The thing is i am making Stamina for the Sprinting and theres a problem with while loop that if i press shift a 2nd time (i know the issue but i couldn’t find a way to fix it) its going to start another while loop and i want that it just cancels it but the stats don’t reset.

Here’s the script: (And btw… is there any better way to make the stamina regen than using while?)

local character = Player.CharacterAdded:Connect(function(character)
	local SprintAnimation = game.ReplicatedStorage.Animations:WaitForChild("Sprinthold")
	local UIS = game:GetService("UserInputService")

	

	local Completly_Stamina_dry = false -- if its completly dry u need to wait to fill it completly up

	local Stamina = 6 -- Max Stamina in Seconfs
	local StaminaUsing = false --the idea is that i can't regen if u are using it
	
	while Stamina <= 5 do
		if StaminaUsing == false then
			print(Stamina)
			Stamina = Stamina + 1
			if Stamina == 6 then
				Completly_Stamina_dry = false
				return
			end
			wait(1)
		end
		return
	end
	
	UIS.InputBegan:Connect(function(input)
		if Completly_Stamina_dry == false then
			if input.KeyCode == Enum.KeyCode.LeftShift then
				StaminaUsing = true
				Module.SprintStart(SprintAnimation, ViewModel)
				character.Humanoid.WalkSpeed = 32
				while Stamina > 0 do

					Stamina = Stamina - 1
					if Stamina == 0 then
						Completly_Stamina_dry = true
						Module.SprintStop() --for sprinting
						character.Humanoid.WalkSpeed = 16
						return
					end
					wait(1)
					print(Stamina)
					UIS.InputEnded:Connect(function(inputEnd) --should cancel it (it doesn't)
						
						if inputEnd.KeyCode == Enum.KeyCode.LeftShift then
							StaminaUsing = false
							Module.SprintStop()
							character.Humanoid.WalkSpeed = 16
							return
						else
							return			
						end

					end)
				end
			end		
		end
	end)
end)```