How to pause and unpause animation based on Character Movement?

I want a script that uses crouching animation, and when pressing a key it enables (but animation speed is 0) when character is moving animation speed is 1, and when character stops moving animation speed is 0 again. If they press the hotkey again, they are back to walking.

I have a script but there’s a problem where it only detects when I press the hotkey, not while I am walking.
Video showing problem & what I want:

The script I have currently:

local Hotkey = "C"
local PlayerSerivce = game:GetService("Players")
local Player = PlayerSerivce.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local AnimationID = game:GetService("ReplicatedStorage").Crawl.AnimationId
local CharacterAnimation
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode[Hotkey] then
		animation()
	end
end)
function animation()
	if Character then
		local CrawlAnimation = Character:FindFirstChild("AnimationCharacter")
		if CharacterAnimation then
			CharacterAnimation:Stop()
		end
		if CrawlAnimation then
			if CrawlAnimation.AnimationId == AnimationID then
				CrawlAnimation:Destroy()
				return
			end
			CrawlAnimation:Destroy()
		end
		local Animation =Instance.new("Animation",Character)
		Animation.Name = "AnimationCharacter"
		Animation.AnimationId = AnimationID
		CharacterAnimation = Character.Humanoid:LoadAnimation(Animation)
		if Humanoid.MoveDirection.Magnitude > 0 then
			CharacterAnimation:Play()
			CharacterAnimation:AdjustSpeed(1)
		end
		if Humanoid.MoveDirection.Magnitude <= 0 then
			CharacterAnimation:Play()
			CharacterAnimation:AdjustSpeed(0)
		end
	end
end

Fixed it!

local Hotkey = "C"
local PlayerSerivce = game:GetService("Players")
local Player = PlayerSerivce.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local CharacterAnimation
local Crawling = false
CharacterAnimation = Character.Humanoid:LoadAnimation(game:GetService("ReplicatedStorage"):WaitForChild("Crawl"))
local function Animate()
	Humanoid.WalkSpeed = 8 -- WalkSpeed Change
	if not Crawling then
		CharacterAnimation:Play()
		CharacterAnimation:AdjustSpeed(0)
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
		Crawling = true
		Humanoid.Running:Connect(function(Speed)
			if Speed > 0 then
				CharacterAnimation:AdjustSpeed(1)
			else
				CharacterAnimation:AdjustSpeed(0)
			end
		end)
	elseif Crawling then
		Crawling = false
		Humanoid.WalkSpeed = 16 -- WalkSpeed Change
		CharacterAnimation:Stop()
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, true)
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
	end
end

game:GetService("UserInputService").InputBegan:Connect(function(InputObject, GameProcessedEvent)
	if InputObject.KeyCode == Enum.KeyCode[Hotkey] then
		Animate()
	end
end)