I suggest using the search function as this question already seems to have been answered before:
Either way, as the solution says you are probably best of making the player die after reaching a health value of 0.1 or below and making sure your weapons won’t kill the player if they are already at this value.
When a Humanoid reaches 0 health, it enters the Death state which cannot be exited. You can prevent the death state by hacking it off but relying on hacks is a bad plan. So you have three options: custom health tracking, clamping the health above a certain threshold and determining anything near the health floor (e.g. <1 health) as a death state or propping up an artificial character model after the death of the original. I recommend the former two, especially the second, over the latter.
if Character.Name = game.Players:FindFirstChild(Character.Name) then
if Character:FindFirstChild("Humanoid").Health == 0 then
I didnt understand too much what you said,but this may be the solution(I’am not too sure if it will work)
I’m no scripting master but isn’t there a way to keep all of the player’s joints welded together even after they die? Also I’m sure there’s a way to decrease the player’s HP to 0 and not kill them. Also make sure the script is not inside a LocalScript but just a regular Script.
Yes, you can preserve joints on death. You can keep Humanoids alive at 0 health as well but hacking the death state off is not recommended, you should always keep a minimum threshold such as 0.01 health that’s maintained by setting the health to the result of math.max between 0.01 and the new health (>0.01 will return the new health, <0.01 will return 0.01).
As genious said,there is an propertie at an humanoid,“BreakJointsOnDeath”,but i dont know how to change it from studio,but from script it may be possible.
if ChildAdded.Name == game.Players:GetPlayerFromCharacter(ChildAdded.Name) then
local ChildAdded = PlayerCharacter
while true do
PlayerCharacter.Humanoid.BreakJointsOnDeath = false
I added an while loop,because PROBABLY,the propertie disables every death the player has(I’am not very sure if this code will work)
Setting a Humanoid’s health to 0 will kill it. That’s not what I said. What I said was to clamp the Humanoid’s health, which can be done by choosing the maximum value between a small threshold and the current health. If it is above the threshold it will set the health to that number, but below it will choose that number.
Another option is to save the players location before death, save their tools and just about everything, and then call Player:LoadCharacter(), destroy the force field, and put everything you saved from their last body back into the character and CFrame it to the saved location.
The explanation is in both the posts I made on this thread, with a more explicit code sample showing that in the second post. Use HealthChanged to figure out when the Humanoid’s health changes and use a function from the math library to keep their health above a certain value.
I’m not the one looking for help though. Additionally, worth quickly saying, but Humanoids can’t come back from the Dead state. That’s why I mentioned in all my posts above that Humanoids need to have their health clamped to a small value and you need to simulate death/knockouts yourself.
You can somehow survive Humanoid.Health = 0 by using Humanoid.HealthChanged and checking if health is 0 then change it to a positive nonzero number.
I only tested it in Studio, so im not sure if it works in the actual game
Edit: I tested it in-game and it still works, but this is only for Humanoid.Health = 0 and not Humanoid:TakeDamage() or Humanoid = Humanoid - number
In that function you give damage to the given humanoid.
Heres an example function, this does not completely do everything. It does have some bugs because I just wrote it based on what my brain says. You should be able to see what im trying to say by reading the script.
function module.GiveDamage(damage, targetHum)
local knockedDownAnimation = script.Animation -- Change this to where ur animation is
if (targetHum.Health - damage > 0.1) then
-- If the damage does not reach the 0.1 mark then you wanna give the damage
targetHum.Health = 0.1
local load = targetHum:LoadAnimation(knockedDownAnimation)
-- Make sure to have an animation when a player is knocked so that you have a animation base
targetHum.Parent.HumanoidRootPart.Anchored = true
targetHum.Parent.HumanoidRootPart.Anchored = false
repeat wait() until targetHum.Health > 50