How Do I Play 2 Animations?

Hey, I’m trying to make two animations play. One plays when the pet is in idle mode and the other when the pet is moving. The one that plays when the pet is moving works fine, but the idle one doesn’t. The pet just shakes vibrantly as shown below.

https://gyazo.com/f58a9e9e59ffb4bc113d30fc800c52b5

Script

local animation = Instance.new("Animation")
local animation2 = Instance.new("Animation")
animation.AnimationId = "https://www.roblox.com/asset/?id=6351842291"--Idle animation
animation2.AnimationId = "https://www.roblox.com/asset/?id=6347758474"--Walking animation


local AnimationController = script.Parent:FindFirstChild("AnimationController")

local animationTrack = AnimationController:LoadAnimation(animation)--Moving animation
local animationTrack2 = AnimationController:LoadAnimation(animation2)--Idle animation


animationTrack2:Play()--Makes the idle animation play

--if the pet is moving then have the movement animation play and idle animation stop playing
animationTrack:Play()
animationTrack2:Stop()

--if the pet is not moving then have the movement animation stop playing and play the idle animation
animationTrack2:Play()
animationTrack:Stop()

Please note that this is not the full script. The script is able to properly check if the pet is moving or not; it’s just the animation part that isn’t working.

Thank you for your time!

I don’t see anything wrong with that script, unless I’m missing something. So, I think that the problem lies in the rest of your script.