How to make this script stop jittering

When Stamina goes down to 1 I want it to have a cooldown instead of the camera jittering in and out.

local UIS = game:GetService("UserInputService")

local Sprinting = false

local Key = Enum.KeyCode.LeftShift

local Humanoid = Character:WaitForChild("Humanoid")

function UpdateBarSize()

	Bar.Size = UDim2.fromScale(Power * .1, 1)
end

function StartRun()

	Tween1:Play()
	Humanoid.WalkSpeed = Run
	Power -= .03
end

function StartWalk()

	Tween2:Play()
	Humanoid.WalkSpeed = Walk
	Power += .01
end

function InputBegan(Input: Enum.KeyCode, gpe: boolean)

	if Input.KeyCode ~= Key or gpe or Sprinting then return end

	Sprinting = true
end

function InputEnded(Input: Enum.KeyCode, gpe: boolean)

	if Input.KeyCode ~= Key or gpe then return end

	Sprinting = false
end

UIS.InputBegan:Connect(InputBegan)
UIS.InputEnded:Connect(InputEnded)

while true do

	if Sprinting then

		if Humanoid.MoveDirection.Magnitude > 0 and Power > 0 then

			StartRun()
		else

			StartWalk()
		end

	elseif not Sprinting and Power < 10 then

		StartWalk()
	end

	UpdateBarSize()

	task.wait()
end

StartRun and StartWalk are being called at a rate of task.wait() instead of when they are just beginning.

I suggest you check:

if tween1.PlaybackState~=Enum.PlaybackState.Playing then
  tween1:Play()
end

And then the same for tween2

It’s just jittering more than usual…