Animation not playing and I can't figure out why!

So I’m making a story game with my dev team (I’m the scripter) and things have been going well until we had trouble playing an animation to the NPCs. I made sure that the animation priority was the highest (Action) and it still won’t play I also made it so when the animation is playing, I disable the character animation script so it doesn’t interfere with it. Here is the code responsible for it:

function PlayAnimation(character, id, stopLoop)
	if character:FindFirstChild("Humanoid") then
		local animation = Instance.new("Animation", script)
		animation.AnimationId = "rbxassetid://" .. id
		local animationTrack = character:FindFirstChildOfClass("Humanoid"):LoadAnimation(animation)
		animationTrack.Priority = Enum.AnimationPriority.Action
		animationTrack:Play()
		if stopLoop then
			if animationTrack.Looped then
				animationTrack.DidLoop:Connect(function()
					animationTrack:Stop()
				end)
			end
		end
		return animationTrack
	end
end

function ToggleAnimation(character, bool)
	character.Animate.Disabled = not bool
end

ToggleAnimation(game.Workspace.James, false)
PlayAnimation(game.Workspace.James, 5514997964, false)
ToggleAnimation(game.Workspace.Jack, false)
PlayAnimation(game.Workspace.Jack, 5514997964, false)

“James” and “Jack” are both NPCs located in Workspace and I could get other animations to load for it like the point emote and a custom sword slash animation I made. I honestly don’t understand why it won’t work. Is this a bug or not? Let me know!

For starters, make sure you preloading the animation.

It doesn’t even play at all. Even after a minute, it still doesn’t play.

Setting the Animation priority does not work through a script you have to do it manually in the animation editor.

Who owns the animation? And who owns the game you’re trying to play it on?

I also manually made the priority to Action

The group owns the animations.

And I also own the group for the game

As @Syntheix was alluding to, load your animation tracks once per character load.
Also, remove ToggleAnimation()

does loading an animation take more than a minute?

No, of course there’s more going on. I missed the bit of text in your message after your code. Have you
tried your animations on your player and do they work that way?

NPCs should be animated with an animation controller instead of a humanoid.