Reviving Humanoid after .Died

Hello.

I am trying to revive the player’s humanoid after it’s state is set to Dead.
This is currently what I’m trying to do:

humanoid.Died:Connect(function()
    humanoid:ChangeState(Enum.HumanoidStateType.None)
    humanoid.Health = 100
end)

However, I can’t seem to able to change the Health after the state is set to Dead.
Is it possible?

Thanks in advance!

3 Likes

I would make the health go to 5 or less. Then set a bool value called dead to true. Then set health to 100. From what I understand once player is dead it’s dead.

3 Likes

I see.
The rest of my code relies on the Died event to be fired.
Isn’t there a way around?

1 Like

Not that I know of. I would just check the values of health the. Change it to 100 as it gets below 5 or less

I did it once with a NumberValue inside the player’s character called FakeHealth.
However, I’m really hoping it’s possible to change this behavior, otherwise I’ll have to change a lot in my current code.

Well tour current function only fires when it dies. So that’s the only real way to do it. You could just check player health without a value and if plr health <= 5 then revive

Sounds like a hacky solution. I don’t really understand why ROBLOX won’t allow changing the Humanoid’s state after dying.
Even using :ChangeState() won’t change it. Apparently it gets locked or something.

Yeah, sorry about that. You just need to check health.

You can probably use :GetPropertyChangedSignal(property) and check if the value is at 5 if you want to rely on Samjay22’s method.

1 Like

Ok!
I’ll leave the thread open to see if someone else can come up with any ideas =)
Thank you, @samjay22.

I said properychanged already didn’t I? Ohh I edited the comment sorry.

I think it is because all the joints break on death…
If the neck and the waist gets destroyed then there is no way to revive the character, And also changing the state to Enum.HumanoidStateType.None after being dead is of no good…

So whenever you need to revive the player :-

  1. First disable the Enum.HumanoidStateType.Dead humanoid state
  2. Then change BreakJointsOnDeath property of the humanoid to false

So try using this…

humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
humanoid.BreakJointsOnDeath = false

humanoid.Died:Connect(function()
    humanoid:ChangeState(Enum.HumanoidStateType.None)
    humanoid.Health = 100
end)
3 Likes

Tried the code above.
No success.
For some reason, when the player dies, it changes the humanoid’s state to Dead, no matter what.
Any other ideas?

I would take a look at this post, they have some good information

Another way to deal with this situation is to save the position the player died and TP them back

So just doing :LoadCharacter(), waiting for the HumanoidRootPart and teleporting to the position?

No, I mean you log the position when the player dies, then load the character

humanoid.Died:Connect(function()
   local pos = humanoid.Parent:FindFirstChild("HumanoidRootPart").Position
   local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
player:LoadCharacter()
   player.Character:WaitForChild('HumanoidRootPart').CFrame = Cframe.new(pos)
   
   
end)

Written on mobile so there could be some errors, just understand the general point :slight_smile:

1 Like

Okay!!
Thank you.

Gonna leave this open to see if someone can come up with another solution. I didn’t want to do :LoadCharacter() again. "/

1 Like

Still haven’t found a solution? I am now trying to solve this problem too
Now I do it like this … but it seems to me that this code is vulnerable (The client may simply not send RemoteEventUpdateHP:FireServer())

LocalScript:

Summary
local ReplicatedStorage = game:GetService("ReplicatedStorage") --
local RemoteEventUpdateHP = ReplicatedStorage:WaitForChild("RemoteEventUpdateHP")
local humh1 = game.Players.LocalPlayer.Character:WaitForChild("Humanoid",5)

local function UpdateHP()
if humh1.Health < 5 then
RemoteEventUpdateHP:FireServer()
end
end
humh1.Changed:Connect(UpdateHP)

ServerScript:

Summary
 local ReplicatedStorage = game:GetService("ReplicatedStorage")
 local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEventUpdateHP")

 local function onUpdateHP(player)
 local TytHuma = player.Character:FindFirstChild("Humanoid")
 TytHuma.Health = 20
 --Here I want to insert an animation of a lying character
 end
 remoteEvent.OnServerEvent:Connect(onUpdateHP)

This method makes me very angry, besides, I see at least 2 games done somehow differently … I feel like they just somehow revive a dead player

I would suggest something similar to the marked solution.

You can set the Players MaxHealth to 105 rather than 100 - Because of the <5 this means the Player only has 95 health.

Going from this, you could use .Changed events or .HealthChanged.

An alternate solution will be to record the humanoid’s root part CFrame right before it resets, and then teleport the player to that CFrame once it dies and respawns.