Jump cooldown script not working

so i have this script where it takes away a player’s stamina when they jump but for some reason the isJumping = not isJumping part is not allowing the player to jump even when the stamina is full. any help?

script:

local bar = script.Parent

local stamina = 100
local staminaRate = 0.1


local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local humanoid = char:WaitForChild("Humanoid")


local isJumping = false

local jumping = humanoid.Jump


local uis = game:GetService("UserInputService")


humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
	if stamina == 0 then return end

	isJumping = not isJumping

	if isJumping then
		humanoid.JumpPower = 50
	else
		humanoid.JumpPower = 0
	end
end)


while wait() do


	if stamina == 0 and isJumping then

		isJumping = false
		humanoid.JumpPower = 0
		wait(5)
	end


	if isJumping then
		stamina = stamina - 5
		wait()
	else
		stamina = stamina + 5
		wait()
	end


	stamina = math.clamp(stamina, 0, 100)

	bar:TweenSize(UDim2.new((1/100) * stamina, 0, 1 ,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1)
end

i already fixed this now so uh yeah