How can i unload an animation?

Hello!

I have an animation playing but its lopping. how can i make it play and then make it stop at a certain point?

Code:

local Controller = friend.Humanoid
		
		local newAnimation = Instance.new("Animation", friend)
		newAnimation.AnimationId = "rbxassetid://10713966026"
		
		Controller:LoadAnimation(newAnimation):Play()

wait(1)
newAnimation:Destroy()

1 Like

if you want to stop it you can just use :Stop() on the track :

local Controller = friend.Humanoid
		
local newAnimation = Instance.new("Animation", friend)
newAnimation.AnimationId = "rbxassetid://10713966026"
		
local track = Controller:LoadAnimation(newAnimation) --create a variable for your track
track:Play()

task.wait(1) --btw you should use task.wait() bc wait() is deprecated
track:Stop()

Hope this helped you!

1 Like

Wow,
I tried :destroy(), :break()
and never realized that i could just do :stop()
Thanks you lol!

np, for for this type of stuff you should check out the documentation it’s very well explained and complete^^

1 Like

This is what I discovered about unloading animation.
But from what you describe, I’m not sure unloading is the issue

1 Like

Also, i do have 1 question.

Whats the difference between Humanoid:LoadAnimation() and Humanoid.Animator:LoadAnimation()

it’s the same thing, exept that Humanoid:LoadAnimation() is deprecated and for some reason they changed it to Humanoid.Animator:LoadAnimation() both are working but Humanoid:LoadAnimation() shouldn’t be used for new work

1 Like

There is one little thing I noticed about the Animator.
If the Animator is created from the server, when the Character is loaded, animations will replicate when played.
If for some reason the Animator is created on the client, Animations played will not replicate.

1 Like

That’s perfect lol! The system i’m using the animation for is client sided, so i am not looking for lag

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.