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)
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.
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.
^^^ 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.
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.