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!