I see.
The rest of my code relies on the Died event to be fired.
Isn’t there a way around?
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.
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 :-
- First disable the Enum.HumanoidStateType.Dead humanoid state
- 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)
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
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. "/
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.
This is not beautiful and does not happen instantly - first there is a spawn on the spawn (the player sees his character on the spawn) and then the player appears at the place of death
100% there is some other solution and I think it should be simple
In one game, the player simply rises from the state of death and that’s it. At the same time, if you shoot at a dead player, nothing happens, he does not teleport anywhere, he just lies
UPD:
It looks like they are using this
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local Humanoid = char:WaitForChild("Humanoid",5)
Humanoid.HealthChanged:Connect(function (newHealth)
Humanoid.Health = math.clamp(newHealth, 0.1, Humanoid.MaxHealth)
end)
end)
end)
This function is inserted into a regular Script .
It does not allow the HP value to fall below 0.1
Without any FireServer and other things
It is also worth adding a check here and if the player’s HP == 0.1 - load the animation of the player falling on his back
thx for the information ı really need to learn this:)