Stamina recharging when it's not supposed to

  1. What do you want to achieve?
    Stamina recharging when the player isn’t using a sword

  2. What is the issue?
    The stamina recharges even while the player is still using a sword

  3. What solutions have you tried so far?
    I tried checking if the “isusing” variable is true but that didn’t work

Here is my code:

if command then
						if command == "Disable" then
							activeHitboxes[sword]:HitStop()
							task.wait(5)
							if player.IsUsing.Value == true then
								player.IsUsing.Value = false
							end
						end
					else
						player.IsUsing.Value = true
						player.Stamina.Value -= 5
						activeHitboxes[sword]:HitStart()
					end

And here is the code for recharging

while task.wait(0.1) do
		while stamina.Value < 100 and stillUsing.Value == false do
			stamina.Value += 1
			task.wait(0.1)
		end
	end