Hello! Recentl,y I have release Duo emotes in my game and since then animations keep breaking. The weird thing is: The duo emotes are not breaking at all, it’s the things which have been working without problems before. I have an animation handler where I load animations and play them instantely, for example fo rusing a tool or drinking. Now, it prints me the error of that the limit AnimationTrack Limit of 256 is being exceed for one animation and now I am asking: How can that be possible when I just added duo emotes??? I have not changed the main animating script at all. Someone please help me.
Make sure you are only loading the animation once, aka.
local Animation = Animator:LoadAnimation("Animation") -- Don't have this everytime the player needs to play the animation
Animation:Play()
Well, this was never a problem before. How would I do that tho? A table with the loaded animations???
Yeah, a table with your loaded animations may work. The problem with this error is that it’s pretty obscure and I don’t think anyone has found a one way solution for it.
You may want to make something like an animation handler. You can do this just by having a module script with an array of all your loaded animations, you can either have a premade one inside the (gui,playerscripts,startercharacterscripts), or you could have a module script with a table called “animations” in replicated storage and then on the client when the player loads up add in all the loaded animations into the table.
-- Localscript in startercharacterscripts
for _, animation: Animation | Instance in (ReplicatedStorage:FindFirstChild("Animations"):GetChildren()) do
AnimationHandler.AddAnimations(Humanoid:LoadAnimation(animation))
end
AnimationHandler.Animations["Run"]:Play()
-- Modulescript in replicatedstorage
local module = {}
module.Animations = {}
function module.AddAnimations(Animation, Humanoid)
module.Animations[Animation.Name] = Animation
end
return module
Don’t load animations if you don’t need to have them ready in case they play afterwards. For example if you know an animation is a fight animation and only plays during a fight, don’t load it while a player isn’t fighting. Also make sure to call :Destroy()
on the animation track after you don’t need it anymore. You should also cache your currently used animations so multiple scripts don’t need to load them on their own causing duplicates.
This is an optimization issue, you need to determine how many animations a player needs ready at a specific moment in time.
You can think of loading animations as preloading assets, you don’t want to preload the same asset over and over again, but you also don’t want to be loading unnecessary assets.