Preventing joints from breaking on death

I’m currently trying to make a custom death that allows for interactions with the body, but on death the R6 character would fall apart, at least for other clients. The body would be attached on the server and the client of the one that died, but everyone else sees the joints break. I’ve tried unsuccessfully to use Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false) on client and server alike, but the outcome is the same. Any tips?

--Server
game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local hum = char.Humanoid
		game.ReplicatedStorage.Remotes.Ragdoll:FireAllClients(hum)
		hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false) 		
		hum.BreakJointsOnDeath = false
		hum.HealthChanged:Connect(function(hp)
			if hum.Health <= 0.1 then
				hum.Health = 1
                --do what i intend
			end		
		end)
	end)
end)

--Client
game.ReplicatedStorage.Remotes.Ragdoll.OnClientEvent:Connect(function(toggle)
	toggle:SetStateEnabled(Enum.HumanoidStateType.Dead, false) 
end)

Killer’s POV
a

Dead Person’s POV
fa679cf94dce26d0323c61271fe638d3

Server POV
a

2 Likes

There’s a new property of the Humanoid called BreakJointsOnDeath. It appears to be live in studio however I’m unsure if it is live in servers.

Release notes here

5 Likes

Well, it might be easier to use a custom health bar and just store their health as a value in their character instead of using humanoid’s.

I’ve tried using that too, but no luck there either.

Attempting to toggle this property on a Humanoid in Studio does not work. I would assume it’s not enabled.

I’m debating doing this if I can’t figure out a fix for it.

Use the custom health bar so that the default death will not run when humanoid.health reaches 0. Create a clone of every character and store it in a folder. Then upon the death of a character, give a copy of that character (from the folder) to each of the other client’s camera and set it to the same location of the player, but with a health of 0. This will make it a local model so only the other clients will see it, and it will fall apart in the place of your character since its health is 0. At the same time, you’ll need a local script in each player to recognize when another player dies, and then do workspace.WhoEverThePlayerIsThatDied:Remove() in the local script, so the real you will not be visible to anyone else. That might work, but will take some effort, good luck if you try this method. :stuck_out_tongue:

The only issue here, the original player will still stay in the same position, but instead one, you see two players now.

I guess the only thing you can do is use plr:LoadCharacter() to prevent duplicates from showing. But I’m not too sure on this solution in general.

At the same time, you’ll need a local script in each player to recognize when another player dies, and then do workspace.WhoEverThePlayerIsThatDied:Remove() in the local script, so the real you will not be visible to anyone else. That might work, but will take some effort, good luck if you try this method. :stuck_out_tongue:

^^^ That part of what I said should account for other clients seeing two of you.

My ragdoll doesn’t make a clone of the character, it uses the actual character model. I have it in a system where I can toggle it on and off and I’d like to toggle it on when someone dies, but this joint breaking setback - resulting in invisible humanoids- is setting me back.

What about toggling it at 1 health

I would assume this is because the death state activates before the health can be successfully changed. I have used a script before to prevent death and it seems to work in terms of not showing joint breakage on either environment. Perhaps you can give it a go.

hum.HealthChanged:Connect(function (newhp)
    hum.Health = math.clamp(hum.Health, 0.1, hum.MaxHealth)
    if some_condition_true_about_newhp then
        -- do what you intend
    end
end)

Throw that in the server code as opposed to what the current HealthChanged function looks like. Don’t think you’ll need to modify any state types on or from the client.

You can use a Ragdoll on death script that welds the character part’s together for now.

1 Like