How to revive Humanoid after the .Died signal?

Hello!

So these days I’ve been working on exploding objects. For example, an exploding gas tank. Everything works normally, after the object is shot several times, the Humanoid dies (.Died) and then the effect of the explosion is triggered.

I was able to create my own way of regenerating the object, by cloning a copy of the object (ReplicatedStorage) and setting it’s Parent to Workspace, placing it in the same position and orientation.

Is there any other easier way to revive Humanoid after it dies?
It would be much better and easier if I could somehow revive the same Humanoid that died.

1 Like

Detect when the player would die, then prevent the death by keeping hp >1

1 Like

For example. When Humanoid.Health <= 40 ?

yes, here’s a simple code that should work:

game.Players.LocalPlayer.Character:WaitForChild("Humanoid").HealthChanged:Connect(function()
game.Players.LocalPlayer.Character.Humanoid.Health = 40
end)

this would prevent the humanoid from dying, just make a if statement to check if ther health goes below 1!

game.Players.LocalPlayer.Character:WaitForChild("Humanoid").HealthChanged:Connect(function()
	if game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Health <=1 then
		game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Health = 40
	end
end)

Yes, it works.

Thank you.

But what if I wanted to add a wait delay before it regenerates? (Let’s say wait(2) )

2 Likes

you can make the person crawl, like he’s downed and need to be healed, waiting 2 seconds will result in it breaking bc it will kill the person and will respawn before the cooldown stops

or if you want simplier, you give the person 1 health while he’s in a ragdol state then heal him

I’m trying to make a gas tank that explodes on a .Died signal regenerate, not a player. If I add wait(2) delay to the script, random player can hit the object again in the meantime, and <=1 will no longer count. This means that the object will not even regenerate after those 2 seconds.

add a debounce, it will fix it and prevent the players from doing anything to it

1 Like

How could I add a debounce to the Humanoid receiving damage?

Maybe I should make it indestructible (MaxHealth, inf) in the same time, and then add the wait delay.

good idea, for it to not take damage its really simple, you calculate how much damages it takes and add it back

1 Like

Works perfectly! Thanks for your help.

This won’t actually do anything because its in a local script, you use LocalPlayer so I assume you mean a local script, but changing the health locally won’t help if the health is being taken away on the server, as the humanoid would still die on the server.

True, but I think he wrote that just as an example.

This was a fun problem to solve for me. I use skinned meshes. When skinned meshes die, they go to T pose. It’s looks dumb. I had to postpone death, so that I could play a death animation and manually kill critters mid-animation.

Here’s some of those steps:

  • Introduce a “DEAD” tag under CollectionService. Anything with this tag is ignored for all damage and attacks. This replaces 0 health and the .Died event.
  • I use a debounce DURING death.
  • I prevent death with this code:
						if defender.Humanoid.Health <= attackDamage and defender.Humanoid.Health > 0 and not CollectionService:HasTag(defender, deadTag) then
							CollectionService:AddTag(defender, deadTag)
							if not deathDebounce[defender] then 
								deathDebounce[defender] = true
--  start death animation, wait 3, destroy
                           end
						else
							defender.Humanoid:TakeDamage(attackDamage)
						end
1 Like