How can i destroy/remove loaded animationtracks after played

I was trying to remove loadedanimations from the humanoid but i don’t know how. I tried using :Destroy() on the instance but it didn’t seem to work and for some reason when i use .Stopped:wait() on the animationtrack it wouldn’t show this error anymore image

Scripts i used:

Script1
 local Loaaaadanimation 
    for i = 0,300,1 do
	
	local humanoid  = script.Parent:WaitForChild("Humanoid")
	local Animation = Instance.new("Animation")
	Animation.AnimationId = "rbxassetid://5718899990"
	Animation.Parent = script.Parent
	Loaaaadanimation = humanoid:LoadAnimation(Animation)
	Animation:Destroy()
	Loadanimation:Play()
	Loadanimation:Destroy()

end
Script2
local Loaaaadanimation 
    for i = 0,300,1 do
    	
    	local humanoid  = script.Parent:WaitForChild("Humanoid")
    	local Animation = Instance.new("Animation")
    	Animation.AnimationId = "rbxassetid://5718899990"
    	Animation.Parent = script.Parent
    	Loaaaadanimation = humanoid:LoadAnimation(Animation)
    	Animation:Destroy()
    	Loaaaadanimation:Play()
    	Loaaaadanimation:AdjustSpeed(1234123412341234)
    	Loaaaadanimation.Stopped:wait()
    end

In your script you are loading the same animation on top of the player over 300 times.

There is a limit, you are only allowed to load 256 animations for a single animator.

You can load animations outside of the loop, and still play them by refrence

LoadedAnimation = humanoid:LoadAnimation(Animation)

for i = 0, 300, 1 do
    LoadedAnimation:Play()
end

This will only influence the limit by 1 rather then 300.

1 Like

I’m well aware of that. I made that script specifically to test how can i remove them.

1 Like

So you need to load over 256 unique animations per player?

1 Like

that was to see if the error popped out

1 Like

So I don’t understand your question. Could you explain why you would need to destroy/remove loaded animations?

I don’t think you can remove loaded animations, maybe you could replace the Animator for the player if you needed to load different ones.

1 Like

How could i replace a loaded animation track?

1 Like

I don’t think you can replace animation tracks,
Please explain why you would like to replace them.

I want to add a different animation track each time an event is fired but i don’t want to load them in advance.

The problem with this is you’ll exceed the limit after playing it 256 times.

You should be loaded them in advance.

If for some reason, it’s better for you to load them as they come up, just make sure that your only loading each unique animation once.

local Animations = {
false, false, false
}

if Animations[1] == false then
    Animations[1] = Humanoid:LoadAnimation(animationID1)
else
    Animations[1]:Play()
end
1 Like

you know why when I use. Stopped:wait () it wont count towards the limit.

Maybe it’s not iterating through all of them??

Cause could potentially be it’s a looped animation and .Stopped:wait() never fires??
if not I have no idea.

1 Like