Running animation playing while standing still

I have this run script that I am using with animations, however, I am having the issue where when holding down shift, the animation plays regardless of if you are standing still or not.

local UIS = game:GetService("UserInputService")

local animation = script.Parent.Humanoid:LoadAnimation(script:WaitForChild("Animation"))

UIS.InputBegan:Connect(function(input, processed)
	if processed then return end
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.LeftShift then
			game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 24
			animation:play()
		end
	end
end)

UIS.InputEnded:Connect(function(input) 
	if input.KeyCode == Enum.KeyCode.LeftShift then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
		animation:Stop()
	end
end)

bye :sweat_smile:
https://developer.roblox.com/en-us/api-reference/event/Humanoid/Running