Hi, I make a script for when a player dies then all his animations stop, however the print on line 13 does not even get trough. What am i doing wrong?
01 | game:GetService( "Players" ).PlayerAdded:Connect( function (Player) |
02 |
03 | Player.CharacterAdded:Connect( function (Character) |
04 |
05 | repeat wait() until Character |
06 |
07 | local Humanoid = Character:WaitForChild( "Humanoid" ) |
08 |
09 | local Animator = Humanoid:WaitForChild( "Animator" ) |
10 |
11 | Humanoid.Died:Connect( function () |
12 |
13 | print ( "Died" ) |
14 |
15 | local AnimationTracks = Animator:GetPlayingAnimationTracks() |
First, you can delete line 5 it's unnecessary there Second, is there are a 'humanoid.died' stuff? I've never met one. however, I tried rewriting your script
01 | game:GetService( "Players" ).PlayerAdded:Connect( function (Player) |
02 |
03 | Player.CharacterAdded:Connect( function (Character) |
04 |
05 | local Humanoid = Character:WaitForChild( "Humanoid" ) |
06 |
07 | local Animator = Humanoid:WaitForChild( "Animator" ) |
08 |
09 | if Humanoid and Humanoid.Health < = 0 then |
10 |
11 | print ( "Died" ) |
12 |
13 | local AnimationTracks = Animator:GetPlayingAnimationTracks() |
14 |
15 | for _,Animation in pairs (AnimationTracks) do |
16 |
17 | Animation:Stop() |
18 | end end |
19 | end ) |
20 | end ) |
Hope I helped! anyways I'm not an animations specialist