Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my print refuses to print?

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?

game:GetService("Players").PlayerAdded:Connect(function(Player)

	Player.CharacterAdded:Connect(function(Character)
		
		repeat wait() until Character

		local Humanoid = Character:WaitForChild("Humanoid")
		
		local Animator = Humanoid:WaitForChild("Animator")
		
		Humanoid.Died:Connect(function()
			
			print("Died")
			
			local AnimationTracks = Animator:GetPlayingAnimationTracks()
			
			for _,Animation in pairs(AnimationTracks) do
				
				Animation:Stop()
			end
		end)
	end)
end)

1 comment

0

What's line 5 for? Feels like that's kind of unnecessary

1 answer

✓ Accepted answer

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

game:GetService("Players").PlayerAdded:Connect(function(Player)

    Player.CharacterAdded:Connect(function(Character)

        local Humanoid = Character:WaitForChild("Humanoid")

        local Animator = Humanoid:WaitForChild("Animator")

       if Humanoid and Humanoid.Health <= 0 then

            print("Died")

            local AnimationTracks = Animator:GetPlayingAnimationTracks()

            for _,Animation in pairs(AnimationTracks) do

                Animation:Stop()
          end end
    end)
end)

Hope I helped! anyways I'm not an animations specialist

2 comments

0

Thanks, if I remove line 5 then there is an error, in short that the character does not yet exist to play the animation. Humanoid.Died also exists.

0

you can fix that too, player.CharacterAdded:Connect()

This discussion is preserved as it was. New answers, comments, and votes are closed.