Hey I am in need of help with Humanoid states.
Once my player dies, I have changed the state to:
Now, say another player wants to heal the humanoid. How do I change the state so it can run again? I have tried a few ways. But I couldnt figure it out.
Here is what happens:
Thank you, ScottFaber
You should use
state is the Enum HumanoidStateType and can be RagDoll or FallingDown
Apparently, there is no Humanoid:SetState() I just tried it.
My bad, it’s :ChangeState, not :SetState
But it still doesnt allow it to come back from being dead. Like to allow it to regen health and walk around.
If you want the health to go up, why not alter the Health property of the humanoid instead?
I meant. Once the player dies I am going to make them be able to get looted. And revived.
So once revived I want the health to go back up. However if the humanoid is dead and that isnt set to false. The health wont go back up.
The problem is I cant get it to allow the humanoid to do walk around and do the normal stuff.
yeah you can’t revive a player from death. once that
HumanoidStateType.Dead is reached, there’s no coming back. to achieve what you want i can think of two ways to do it:
clamp the player’s health. make a function that checks if the player’s health is about to reach 0 or under, then connect that function to the
HealthChanged event of the humanoid. done right, this will prevent the humanoid from dying. you can script the rest for disabling the player/activating ragdoll/stopping regeneration when the health falls under a certain threshold.
have a fake health bar. instead of using the
:TakeDamage function of the humanoid, make your own custom function that affects your own custom health system. then when the player takes enough damage, you’ll handle all the effects based on the fake health.
You could use Player:LoadCharacter to respawn the player, moving the character immediately to the location it died at. Though I haven’t tested this, so I’m not sure if it’ll be completely seamless.
In the end, I made a custom health value. And used that to detect death and added a custom death animation and respawn function.
Thank you to all those whom tried to help me.