My animations aren't playing and I don't know why

Here’s my code:

local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Walk)

game.Players.LocalPlayer.Character.Humanoid.Running:Connect(function(speed)
	if speed > 2 then
		anim:Play()
		anim:AdjustSpeed(speed/10)
	else
		anim:Stop()
	end
end)

I have no idea why this isn’t working.
If you could help me with this it would be appreciated.

Make sure you changed your Animation Priority to Movement or Action.

Also please don’t run :LoadAnimation() with Humanoid object since it’s currently deprecated. I think you should run it Animator object which will be auto create inside Humanoid. You can find it by doing Humanoid:FindFirstChildWhichIsA("Animator")