Events Not Firing After Instance Destroyed!

Hello, hope you are feeling well! I have an event that waits for an animation to stop to run another piece of code, but here is the problem, that object which is running the animation can get destroyed in the game.

Animation.Stopped:Wait()

If the Model gets destroyed in the middle of the animation, the event will never fire…
How can I fix this. By the way, my game is a survival game, the model I am talking about is an ANIMAL. If someone kills it in the middle of the animation the event doesn’t fire… I really need help on how to fix this. By the way, I ain’t using Humanoids.

Another question is, why does those type of events doesn’t yield if the instance has been destroyed?

If you aren’t using humanoids, then it shouldn’t be too difficult to stop the animation before you clean up the animal.

1 Like

I know this will sound a bit dumb, I didn’t made the animation to loop in the script editor. So what I do is play it once the animation stopped running… How am I suppose to check if it died, if the script got stuck with the :Wait

Just re-import it and check looped, and re-export it.

1 Like

Any other way, than affecting the animation itself?

EDIT: One of my main question is why doesn’t it yield if the instance doesn’t exist anymore…?

If you need to loop an animation, you should just have it loop.

I’m not sure what your code structure looks like. Whatever is handling the animals needs to be able to detect death, stop all animations and clean up other stuff, and then get rid of it.

The reason Stopped is never true is because the animation is never stopped. If it doesn’t exist anymore, there is no animation to reference, and the property will never change because it doesn’t exist.

1 Like

I have a question as well, I was using Animation.Looped = true but this one wasn’t replicating… I made many animations, and I will have to check Looped in them. I ain’t lazy to do this, I want to know why the Animation.Looped = true doesn’t replicate…

Are these animations client side? IIRC animations will only replicate automatically if they are directly connected to a player character, and that character has an Animator in the humanoid, or an animation controller.

1 Like

These animations are playing from the server.

So Animation.Looped should replicate.

1 Like

And you are setting .Looped to true on the server as well?

1 Like

I am using Animation.Looped = true just in the server.

EDIT 1: This one wasn’t replicating, so I just looped the code to play the animation. I know I can do it from the editor, but idk if this is a bug or what with Animation.Looped

EDIT 2: I don’t see in the API reference the Animation.Looped doesn’t replicate… It doesn’t say anything about replication to be honest.

EDIT 3: I am using AnimationController.

I just saw this has been a bug for like 2 years now and still not fix.