I have a system where I change animations depending on a player’s current status. I have extra body parts in my rig and the animations themselves work fine. Let’s say I have two extra limbs, a glass of water and a sandwich. If I have a sandwich in my hand, the animation will play and make him eat it and then it will rest with his arm sticking out, therefore the sandwich is sticking out too, when it is normally attached to his hip. Then I switch to drinking some water, which is currently attached to his hip. The animation will play and he will drink his water, but the sandwich will stay floating in it’s last place before I changed animations. This only occurs IF I have played one of the two animations already. The item stays attached to the hip if it hasn’t been animated already.
So stopping animations will reset them to the hip right? That’s correct, and it does work. However, my code won’t stop the current animations playing. If I run this same code in the command line on play mode, it will work and stop the animation.
I have tried using wait times between switching animations. I have had wait times between the :Stop() function and :Destroy() function. I have done a repeat wait() until thistrack.IsPlaying == false. I am out of ideas, the animation just won’t stop. I have used a print statement to check if the loop runs also, and it does. (Code: print("Destroying: "…thistrack.Name) ). I’d really appreciate any help you guys can give me! Thanks!
function removeTracks(char)
local Tracks = char:FindFirstChild("Humanoid"):GetPlayingAnimationTracks(); -- Get all playing animations from our character
for i, thistrack in pairs(Tracks) do -- Stop and destroy all animations that are playing
thistrack:Stop();
thistrack:Destroy();
end
end