Why does the animation not stop even though :Stop() is called?
I am trying to make a trash can that you can push around and I'm stuck on the idle animation.
This is the code:
01 | isPushed = script.Parent.Pushing |
02 | proximity = script.Parent.BodyAttach.ProximityPrompt |
03 | idleAnimation = script.Parent.BodyAttach.Idle |
05 | function onTrigger(player) |
06 | if isPushed.Value = = false then |
07 | local character = player.Character |
08 | local humanoid = character:WaitForChild( "Humanoid" ) |
09 | local animator = humanoid:WaitForChild( "Animator" ) |
10 | local animateScript = character:WaitForChild( "Animate" ) |
11 | defaultAnim 1 = animateScript.idle.Animation 1. AnimationId |
12 | defaultAnim 2 = animateScript.idle.Animation 2. AnimationId |
13 | animateScript.idle.Animation 1. AnimationId = idleAnimation.AnimationId |
14 | animateScript.idle.Animation 2. AnimationId = idleAnimation.AnimationId |
15 | for i,track in pairs (animator:GetPlayingAnimationTracks()) do |
18 | local playerTorso = player.Character:WaitForChild( "UpperTorso" ) |
19 | M 6 D = Instance.new( "Motor6D" , playerTorso) |
20 | M 6 D.Name = "TrashGrip" |
21 | playerTorso.TrashGrip.Part 0 = playerTorso |
22 | playerTorso.TrashGrip.Part 1 = script.Parent.BodyAttach |
23 | proximity.Style = Enum.ProximityPromptStyle.Custom |
26 | local character = player.Character |
27 | local humanoid = character:WaitForChild( "Humanoid" ) |
28 | local animator = humanoid:WaitForChild( "Animator" ) |
29 | local animateScript = character:WaitForChild( "Animate" ) |
30 | animateScript.idle.Animation 1. AnimationId = defaultAnim 1 |
31 | animateScript.idle.Animation 2. AnimationId = defaultAnim 2 |
32 | for i,track in pairs (animator:GetPlayingAnimationTracks()) do |
37 | proximity.Style = Enum.ProximityPromptStyle.Default |
38 | isPushed.Value = false |
42 | proximity.Triggered:Connect( function (player) |
As you can see there is a loop in both cases that should stop all animations that are playing. But it doesn't stop the idle animation and it only changes if the character moves and becomes idle again.