Hello. I'm making a sprinting animation for my game which works fine, but the animation doesn't play when I'm strafing

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

local UIS = game:GetService("UserInputService")
local debounce = false
local toggle = false

local sprint = hum:LoadAnimation(script.Sprint)

UIS.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.LeftControl and not debounce and not toggle then
		debounce = true
		toggle = true
		
		hum.WalkSpeed = 30
		sprint:Play()
		
		wait()
		debounce = false
	elseif key.KeyCode == Enum.KeyCode.LeftControl and not debounce and toggle then
		debounce = true
		toggle = false
		
		hum.WalkSpeed = 16
		sprint:Stop()
		
		wait()
		debounce = false		
	end
end)

hum:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if hum.MoveDirection == Vector3.new(0, 0, 0) then
		sprint:Stop()
	elseif hum.MoveDirection ~= Vector3.new(0, 0, 0) and hum.WalkSpeed == 30 then
		sprint:Play()
	end
end)

This is the effect in-game: link. Also, ignore the black character.