I have a looped animation named Lie with only 1 keyframe wich is at 0 seconds, the only animated part is the torso and the priority is Action.
I found this and I tried these things but it did not work: https://scriptinghelpers.org/questions/13447/properly-stop-animations
The Stop() function doesen't seem to work.
The animation starts, all prints work right and it gives no error.
I tried starting a new animation wich is blank and has core priority, but it did not work.
Animation ID: c3b2824fa4becf2c6ee2f20972de6604
01 | Mouse = game.Players.LocalPlayer:GetMouse() |
02 |
03 | Prone = false |
04 | Player = game.Players.LocalPlayer.Character |
05 |
06 | Mouse.KeyUp:connect( function (Key) |
07 | print ( "Key " ..Key.. " down." ) |
08 | if Key = = "c" then |
09 | print ( "Prone key down." ) |
10 | local Animation = Player.Humanoid:LoadAnimation(script.Lie) |
11 | if Prone = = false then |
12 | print ( "Prone is false." ) |
13 | Prone = true |
14 | Animation:Play() |
15 | Player.Humanoid.CameraOffset = Vector 3. new( 0 ,- 4 ,- 1.5 ) |
I'd load the Animation outside of the anonymous function's scope.
01 | Mouse = game.Players.LocalPlayer:GetMouse() |
02 |
03 | Prone = false |
04 | Player = game.Players.LocalPlayer.Character |
05 |
06 | Animation = Player.Humanoid:LoadAnimation(script.Lie) |
07 |
08 | Mouse.KeyUp:connect( function (Key) |
09 | print ( "Key " ..Key.. " down." ) |
10 | if Key = = "c" then |
11 | print ( "Prone key down." ) |
12 | if Prone = = false then |
13 | print ( "Prone is false." ) |
14 | Prone = true |
15 | Animation:Play() |
The LoadAnimation method creates a packet of information that is stored inside of the humanoid that will not go away.
It's not a good idea to put it locally inside of the function, because every time a key is up, you're loading more packets information.
Yes, it won't do anything because loading an animation will make the animation dormant. But since you're always playing it within the function, every animation you've loaded will be played, therefore making it impossible for the animations to stop.
That's why I made the Animation
variable a static one, rather than a local one.