How do i stop this animation from constantly playing?

ok. i’ve been working on a sprint script recently and after implementing some stamina stuff, this bug was present before but it got even more noticable. whenever i jump, the fall animation is supposed to play, it does, but then it constantly replays even though it’s not set on loop in the animation maker.

could i get some help? here is the script:

Script
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Stamina = 100
local Running = false

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

UIS.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Running = true
		Character.Humanoid.WalkSpeed = 24
		local Anim = Instance.new('Animation')
		Anim.AnimationId = 'rbxassetid://7384132764'
		PlayAnim = Character.Humanoid:LoadAnimation(Anim)
		PlayAnim:Play()
		while Stamina > 0 and Running do
			Stamina = Stamina - 1
			script.Parent:TweenSize(UDim2.new(Stamina/ 100, 0, 1, 0), "Out", "Linear",0)
			wait(0.06)
			if Stamina == 0 then
				Character.Humanoid.WalkSpeed = 16
				PlayAnim:Stop()

			end
		end
	end
if input.KeyCode == Enum.KeyCode.Space then
local JumpAnim = Instance.new('Animation')
local FallAnim = Instance.new('Animation')
JumpAnim.AnimationId = 'rbxassetid://7391963123'
FallAnim.AnimationId = 'rbxassetid://7397288802'
FallAnimPlay = Character.Humanoid:LoadAnimation(FallAnim)
JumpAnimPlay = Character.Humanoid:LoadAnimation(JumpAnim)
PlayAnim:Stop()
JumpAnimPlay:Play()
	while Stamina > 0 and Running do
wait(0.06)
		if Stamina == 0 then
			Character.Humanoid.WalkSpeed = 16
			JumpAnimPlay:Stop()
			FallAnimPlay:Stop()
		end
	end
end

	if (JumpAnimPlay) then
		wait(JumpAnimPlay.Length)
		FallAnimPlay:Play()
		wait(FallAnimPlay.Length)
	end
end)

UIS.InputEnded:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Running = false
		Character.Humanoid.WalkSpeed = 16
		PlayAnim:Stop()
	end
	if input.KeyCode == Enum.KeyCode.Space then
		JumpAnimPlay:Stop()
		FallAnimPlay:Stop()
		PlayAnim:Play()
	end
	while Stamina < 100 and not Running do
		Stamina = Stamina + 1
		script.Parent:TweenSize(UDim2.new(Stamina/ 100, 0, 1, 0), "Out", "Linear",0)
		wait(0.06)
		if Stamina == 0 then
			Character.Humanoid.WalkSpeed = 16
			PlayAnim:Stop()
		end
	end
end)

here is a video of what happens:

Video

https://i.gyazo.com/2c55384ae356423f298e439433dfbd91.mp4

hope it helps! thank you for reading this!

I re wrote the code you sent here. I also added some extra options at the top of the code

local Options = { -- Manually set these options; For numerical options, set to 0 to disable
	Sprint_Needs_Moving = true, -- Sprinting will count as true if player is moving while holding LeftShift
	Stamina_Regen_Delay = 1, -- How long before stamina regens
	Sprint_Zone = 20, -- Sprinting only continues if held at this point, otherwise wait until stamina is higher

	Jump_Stamina = 20, -- Amount of stamina jumping reduces
	Jump_Spam_Delay = 0.5, -- Disable jumping for a while after falling

	Actions_Pauses_Regen = { -- Actions that pauses stamina from regening; Should be a HumanoidStateType
		Enum.HumanoidStateType.Climbing,
		Enum.HumanoidStateType.Freefall
	}, 
	Moving_Slows_Regen = true, -- Moving slows stamina regen speed
}


-----------------------------------------------------------------------------------------------------------------------------


local UIS = game:GetService('UserInputService')
local Run = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Stamina = 100
local sprintHeld = false

local Frame = script.Parent
local jumpDelay = tick()
local regenDelay = tick()

local Animations = {}
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://7384132764' -- Sprint Animation Id
Animations.Sprint = Humanoid:LoadAnimation(Anim)
Anim.AnimationId = 'rbxassetid://7391963123' -- Jump Animation Id
Animations.Jump = Humanoid:LoadAnimation(Anim)
Anim.AnimationId = 'rbxassetid://7397288802' -- Falling Animation Id
Animations.Fall = Humanoid:LoadAnimation(Anim)

Humanoid.JumpHeight = 0

Humanoid.Jumping:Connect(function(jumped)
	if jumped and Stamina >= Options.Jump_Stamina then
		regenDelay = tick()
		Animations.Jump:Play()
		task.delay(Animations.Jump.Length,function() Animations.Fall:Play() end)
		jumpDelay = tick()
		Stamina -= Options.Jump_Stamina
		Frame:TweenSize(UDim2.fromScale(Stamina/100,1), "Out", "Linear", 0.1)
	end
end)

UIS.InputBegan:connect(function(input,gp)
	if input.KeyCode == Enum.KeyCode.LeftShift and Stamina > Options.Sprint_Zone then
		sprintHeld = true
	end
end)

UIS.InputEnded:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		sprintHeld = false
	end
end)

Run.Heartbeat:Connect(function(dt)
	local moving = Options.Moving_Slows_Regen and Humanoid.MoveDirection.Magnitude > 0
	local humState = Humanoid:GetState()

	local sprinting = sprintHeld and (not Options.Sprint_Needs_Moving or moving)

	for _, action in pairs(Options.Actions_Pauses_Regen) do
		if humState == action then
			regenDelay = tick()
			break
		end
	end

	if Options.Sprint_Needs_Moving then
		if not sprinting and Animations.Sprint.IsPlaying then
			Humanoid.WalkSpeed = 16
			Animations.Sprint:Stop()
		end
	end

	if sprinting then
		Stamina = math.max(Stamina - dt * 15, 0)
		Frame:TweenSize(UDim2.fromScale(Stamina/100,1), "Out", "Linear", 0.02)
		regenDelay = tick()
		sprinting = Stamina > 0
		if not Animations.Sprint.IsPlaying then
			Humanoid.WalkSpeed = 24
			Animations.Sprint:Play()
		end
		if not sprinting then
			sprintHeld = false
			Humanoid.WalkSpeed = 16
			Animations.Sprint:Stop()
		end
	elseif (tick() - regenDelay >= Options.Stamina_Regen_Delay and Stamina < 100) then
		Stamina = math.min(Stamina + dt * 15 * (moving and .5 or 1), 100)
		Frame:TweenSize(UDim2.fromScale(Stamina/100,1), "Out", "Linear", 0.02)
		
		if Animations.Sprint.IsPlaying then
			Humanoid.WalkSpeed = 16
			Animations.Sprint:Stop()
		end
	end

	if Stamina < Options.Jump_Stamina then
		Humanoid.UseJumpPower = false
	else
		Humanoid.UseJumpPower = true
		jumpDelay = humState == Enum.HumanoidStateType.Freefall and tick() or jumpDelay 
		if tick() - jumpDelay < Options.Jump_Spam_Delay then
			Humanoid.UseJumpPower = false
		end
	end
	
	
-----------------------------------------------------------------------------------------------------------------------------


	local checked = false
	if Stamina < Options.Sprint_Zone then
		-- Code here runs repeatedly if Stamina is below the sprint zone
		
		if not checked then
			checked = true
			-- Code here runs once everytime stamina reaches below the sprint zone
		end
	else
		checked = false
	end
end)

The last time i tested this it was working, tell me if something errors.

Edit: more options