Humanoid.Died not firing

Whenever you die for the first time the first script always fires, but after that the second script just straight up does not fire. But if you are in studio it works perfectly fine for some reason :person_shrugging:

game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
	game.Players.LocalPlayer.PlayerGui.ScreenFX["Death Frame"].DeathText.Text = deathMessages[13]
	game.Players.LocalPlayer.PlayerGui.ScreenFX["Death Frame"].Position = UDim2.new(-1.08, 0, 0, 0)
	game.Players.LocalPlayer.FOV.Value = 10
	tweenService:Create(game.Players.LocalPlayer.PlayerGui.ScreenFX["Death Frame"], TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out), finish):Play()
	task.wait(1.5)
	game.Players.LocalPlayer.FOV.Value = 70
	tweenService:Create(game.Players.LocalPlayer.PlayerGui.ScreenFX["Death Frame"], TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out), start):Play()
end)

game.Players.LocalPlayer.CharacterAdded:Connect(function()
	game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
		game.Players.LocalPlayer.PlayerGui.ScreenFX["Death Frame"].DeathText.Text = deathMessages[math.random(1, #deathMessages)]
		game.Players.LocalPlayer.PlayerGui.ScreenFX["Death Frame"].Position = UDim2.new(-1.08, 0, 0, 0)
		game.Players.LocalPlayer.FOV.Value = 10
		tweenService:Create(game.Players.LocalPlayer.PlayerGui.ScreenFX["Death Frame"], TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out), finish):Play()
		task.wait(1.5)
		game.Players.LocalPlayer.FOV.Value = 70
		tweenService:Create(game.Players.LocalPlayer.PlayerGui.ScreenFX["Death Frame"], TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out), start):Play()
	end)
end)

The CharacterAdded event sends a parameter for you which is the character, try using it like this:

local localPlayer = game.Players.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()

local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
	print("humanoid died event fired")
end)

localPlayer.CharacterAdded:Connect(function(character)
	character.Humanoid.Died:Connect(function()
		print("humanoid died event fired")
	end)
end)

If you have any questions, feel free to ask! :wink:

2 Likes

Thank you so much! I couldn’t figure it out for the life of me

1 Like

Just stopped working again after I did nothing…
image
Line 53 is this:

character.Humanoid.Died:Connect(function()

Try this:

localPlayer.CharacterAdded:Connect(function(character)
    local humanoid = character:WaitForChild("Humanoid")
	humanoid.Died:Connect(function()
		print("humanoid died event fired")
	end)
end)

And since it’s inside a gui make sure to turn off ResetOnSpawn or move the script to somewhere else.

1 Like

Edited my message before I saw this, sorry

It worked, thank you so much for the help!

1 Like