Sword idle animation won't stop playing?
Asked by
5 years ago Edited 5 years ago
So when a player dies with the tool equipped, and they respawn, then equip the tool then unequip it, the idle anim is still playing.
01 | local plr = game.Players.LocalPlayer |
02 | local char = plr.Character or plr.CharacterAdded:wait() |
03 | local tool = script.Parent |
04 | local swingsound = tool:WaitForChild( "Swing" ) |
05 | local canattack = tool:WaitForChild( "CanAttack" ) |
08 | local delayForDebounce = . 5 |
10 | tool.Equipped:Connect( function () |
11 | local Equip = script.Parent.Parent.Humanoid:LoadAnimation(script.Sword) |
14 | local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) |
18 | tool.Activated:connect( function () |
19 | if debounce = = false then |
20 | local choose = math.random( 1 , 3 ) |
21 | canattack.Value = true |
24 | local swing 1 animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch 1 ) |
26 | swing 1 animation:Play() |
27 | wait(delayForDebounce) |
29 | elseif choose = = 2 then |
31 | local swing 2 animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch 2 ) |
33 | swing 2 animation:Play() |
34 | wait(delayForDebounce) |
36 | elseif choose = = 3 then |
38 | local swing 3 animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch 3 ) |
40 | swing 3 animation:Play() |
41 | wait(delayForDebounce) |
47 | tool.Deactivated:Connect( function () |
48 | canattack.Value = true |
51 | tool.Unequipped:Connect( function () |
52 | local hum = char:WaitForChild( "Humanoid" ) |
53 | for i, v in pairs (hum:GetPlayingAnimationTracks()) do |