AnimationTrack limit of 256

I’m trying to fix a bug that happens after swinging a sword over 256 times. About halfway through a dungeon, if you’ve been swinging it enough, you’ll stop being able to.

I get an error that says:
AnimationTrack limit of 256 tracks for one animator exceed. No new tracks will be played.
I know the issue, but not how to fix it.

I’ve already tried a couple things so far to fix it, I’ll go in order.

  • Making a StarterCharacterScript that deletes and replaces the animator every 3 minutes or so, the problem is that it would make the tool idle animation be messed up.

  • Making something that stopped all playing animations and then replaced the animator, same issue.

  • Changing the toolscript to load the animation once in the script, with something looking like this:

for i, v in pairs(script:GetChildren()) do
    if v.Name == "ANIM" then
        table.insert(ANIMS,1,"animation")
        ANIMS[1] = script.Parent.Parent.Humanoid:LoadAnimation(v)
    end
end

-- The rest of the script that does stuff here, using ANIMS[num]:Play() to play it.

Problem with this is that I got the same error after a bit.

I’ve probably done a couple more things to see if it worked, but for now I can’t think of any. If you know how to solve this, please tell me. Anyways, thanks in advance.

The solution code you posted should work if you’re using it properly. Caching the loaded animations is the solution.

The code doesn’t work though, so I’m not sure what will.

Can you post the entire script?

I found the problem and tried to fix it, (the problem was that I had a second animation loading itself), but when trying to load it at the start, the script timed out. I think I might know how to fix this one, though.

You can play the same animation more than once. Instead of making a new animation track each time you want to do an attack, you can replay it by using the :Play() method again. This is definitely way better than replacing the animator constantly.

1 Like