Detect if a localplayer died without using StarterCharacterScripts?

I am trying to avoid using StarterCharacterScripts and trying to restart a local script once the player has died. How would I achieve this?

Script:

myHuman.Died:Connect(function()
	attemptingToStop = true
	wait(5.05)
	print("ight ima try to reload the character")
	character = player.Character or player.CharacterAdded:Wait()
end)

Thanks

2 Likes

If you’re using a local script, you pretty much got it.

Just do

local chr = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local myHuman = Character:WaitForChild("Humanoid")

Then use the script you wrote. Put it in StarterPlayerScripts

1 Like

You are connecting to the old humanoid.

Instead, you can do:

local Players = game:GetService("Players")
local client = Players.LocalPlayer

local character
client.CharacterAdded:Connect(function(_character)
    character = _character
    character.Humanoid.Died:Connect(function()
        -- stuff
    end)
end)

Although, why don’t you want to use StarterCharacterScripts?

8 Likes

Thank you.

I was trying to avoid StarterCharacterScripts because I wanted to gain information through a different script, aka the main localscript for my game to keep it simple.

1 Like