HumanoidStateType.Dead, false. How to make a humanoid back on its feet?


I will keep it short and simple.

Here is a snippet of my code:

--Humanoid Death Disabled--
humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
local died = false
	if health <= 0 then
		if not died then
			died = true
			died = false
			humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, true)
			humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)

I am aware that the top method does not work to make the player whose health is at 0 (dead) come back on his feet after 20 seconds. It will just continue being in a platformstanding state. My question is, how would you make it so after 20 seconds, humanoid is back on its feet?

You could probably use Humanoid:ChangeState to force the humanoid into a running state:

-- after waiting 20 seconds...
died = false
1 Like

I remember the idle movement state being RunningNoPhysics, so it’d probably be more appropriate to use that instead to force the Humanoid to an idle state. Running is for active Humanoids performing physics calculations.

Hi, I have tried the ChangeState method with both Running and RunningNoPhysics with no luck.

My humanoid just lays there regening health. How do I make it so the humanoid is no longer under the influence of his health being at 0? So it can get up and start walking after regening health 25.

1 Like

Could you show what you’re currently working with, or has it not changed since you posted it in the OP?

Frankly, anything to do with Humanoids is super hacky, espcially trying to force the death state off. I feel like you’d have more luck using a lower-level hack such as forcing the Humanoid health to be above 0.01 and treating any health below 1 as a pseudodeath state.

There are some example games that you can look at, e.g. Rogue Lineage has this kind of death system where when you die, you drop for 20 seconds and start walking after.

In Rogue Lineage, the character doesn’t actually die, because the health bar is still slightly above 0. I would just do what @colbert2677 described, and just set their health very close to 0 instead. You can just fork the Health script from your in-game character, and make the health bar stop regenerating for a short time before regenerating again if their health is below a threshold.
For example, this would be the default Health script:

local REGEN_RATE = 1/100 -- Regenerate this fraction of MaxHealth per second.
local REGEN_STEP = 1 -- Wait this long between each regeneration step.

local Character = script.Parent
local Humanoid = Character:WaitForChild'Humanoid'

while true do
	while Humanoid.Health < Humanoid.MaxHealth do
		local dt = wait(REGEN_STEP)
		local dh = dt*REGEN_RATE*Humanoid.MaxHealth
		Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)

You can insert an if statement before running the while loop to see if you should make the character stop regenerating. Spoiler, this is pseudocode:

while true do
	if Humanoid.Health < 1 then -- or something
		Humanoid.Health = Humanoid.Health + 1
		-- run the usual while loop
	-- health changed wait
1 Like

You also do need to force clamp the Health. Stopping regeneration at a certain point isn’t enough because if the Humanoid takes a large enough damage value, they will die. Keeping it in the while loop will cause this to happen: setting it immediately upon a registered health change will not.

Humanoid.HealthChanged:Connect(function (newHealth)
    Humanoid.Health = math.clamp(newHealth, 0.01, Humanoid.MaxHealth)

From there you could probably just add an extra condition to that while loop.

while Humanoid.Health < Humanoid.MaxHealth and Humanoid.Health > 1 do