So I am some-what bad at scripting, but I decided to use this script, the script will play the Idle animation however when unequipped the Idle animation will keep playing even though I use :Stop()
Script:
01 | local Tool = script.Parent |
02 | local Animation = Tool.Idle |
03 |
04 | Tool.Equipped:Connect( function () |
05 | local Character = Tool.Parent |
06 | local Humanoid = Character.Humanoid |
07 |
08 | local AnimationTrack = Humanoid:LoadAnimation(Animation) |
09 | AnimationTrack:Play() |
10 | end ) |
11 |
12 | Tool.Unequipped:Connect( function () |
13 | AnimationTrack:Stop() |
14 | end ) |
Well, Uneqquiped function couldn't access AnimationTrack variable because it is a local variable in another function, so I made it a global one, hope it works (:
01 | local Tool = script.Parent |
02 | local Animation = Tool.Idle |
03 | local AnimationTrack |
04 |
05 | Tool.Equipped:Connect( function () |
06 | local Character = Tool.Parent |
07 | local Humanoid = Character.Humanoid |
08 |
09 | AnimationTrack = Humanoid:LoadAnimation(Animation) |
10 | AnimationTrack:Play() |
11 | end ) |
12 |
13 | Tool.Unequipped:Connect( function () |
14 | AnimationTrack:Stop() |
15 | end ) |
This is a quick simple mistake. :Stop() actually doesn’t exist. Here’s an actual script that works! ~~~~~~~~~~~~~~~~ Tool.Unequipped:Connect(function() AnimationTrack:Pause() end) ~~~~~~~~~~~~~~~~~ Thanks!
Removing the local infront of the variable because of the scope.
Reversing the animation would be an option too. https://developer.roblox.com/en-us/api-reference/function/AnimationTrack/AdjustSpeed
1 | AnimationTrack:AdjustSpeed(negative number to play it backwards) |