Gun animation isn't playing?

Hello, I am creating gun animations for my project. However, when trying to input an idle animation in studio testing, it doesn’t play:

This is what it is supposed to look like:

It plays as intended in the animation editor. Anyone got any ideas?

This is the code that includes the animation:

function setupviewmodel(weapon)
	print(weapon)
	WeaponData = require(GunModules:WaitForChild(weapon))
	
	maincf = WeaponData.MainCFrame
	rotationcf = WeaponData.RotateCFrame
	larmcf = CFrame.new(1,-1,-2)
	larmrotatecf = CFrame.new(0,0,0)
	rarmcf = CFrame.new(1,-1,2)
	ammo = WeaponData.ammo
	maxammo = WeaponData.maxammo
	remaining = WeaponData.remaining
	reloadspeed = WeaponData.reloadspeed
	Animator = GunViewmodels.Shotgun.Humanoid.Animator
	Idle = GunViewmodels.Shotgun:FindFirstChild("Idle")
	
	
	WeaponInHand = GunViewmodels:WaitForChild(weapon):Clone()
	WeaponInHand.PrimaryPart = WeaponInHand:WaitForChild("HumanoidRootPart")
	WeaponInHand.Parent = cam
	for i, part in pairs(WeaponInHand:GetChildren()) do
		if part:IsA("BasePart") then
			part.Anchored = false
			part.CanCollide = false
		end
	end
	
	LArm = WeaponInHand:FindFirstChild("Left Arm")
	LArm.PrimaryPart = LArm:FindFirstChild("LeftArm")
	
	RArm = WeaponInHand:FindFirstChild("Right Arm")
	RArm.PrimaryPart = RArm:FindFirstChild("RightArm")
	
	LoadIdle = Animator:LoadAnimation(Idle)
	LoadIdle:Play()
	print("Idle is playing")

Is the game made by yourself or a group? If it’s by a group then you might want to upload the animation for the group and not for yourself.

I uploaded the animation to my account.

Fixed it. Turns out I had to rearrange my variables so that it referred to the correct viewmodel

Here’s the code:

function setupviewmodel(weapon)
	print(weapon)
	WeaponData = require(GunModules:WaitForChild(weapon))
	
	maincf = WeaponData.MainCFrame
	rotationcf = WeaponData.RotateCFrame
	larmcf = CFrame.new(1,-1,-2)
	larmrotatecf = CFrame.new(0,0,0)
	rarmcf = CFrame.new(1,-1,2)
	ammo = WeaponData.ammo
	maxammo = WeaponData.maxammo
	remaining = WeaponData.remaining
	reloadspeed = WeaponData.reloadspeed
	
	
	WeaponInHand = GunViewmodels:WaitForChild(weapon):Clone()
	WeaponInHand.PrimaryPart = WeaponInHand:WaitForChild("HumanoidRootPart")
	WeaponInHand.Parent = cam
	for i, part in pairs(WeaponInHand:GetChildren()) do
		if part:IsA("BasePart") then
			part.Anchored = false
			part.CanCollide = false
		end
	end
	
	LArm = WeaponInHand:FindFirstChild("Left Arm")
	LArm.PrimaryPart = LArm:FindFirstChild("LeftArm")
	
	RArm = WeaponInHand:FindFirstChild("Right Arm")
	RArm.PrimaryPart = RArm:FindFirstChild("RightArm")
	
	Animator = WeaponInHand.Humanoid:WaitForChild("Animator")
	Idle = WeaponInHand:FindFirstChild("Idle")
	LoadIdle = Animator:LoadAnimation(Idle)
	LoadIdle:play()
	LoadIdle.Looped = true
end