I’m making a corpse system with ragdoll, but after the character copies, the body instantly stands up, i tried removing the humanoid, but the clothing falls off. Thanks for any help!
Lock and Anchored the rootpart … just ran into this in some other help.
Can’t have it both ways.
I can’t really anchor it because it first needs to fall to the ground.
when humanoids die, they break all joints
you would have to reweld everything in the corpse (before parenting to workspace), and add a vector force to the primary part or head
That way you use ragdoll. So that isn’t a problem.
Delay that and let them fall. So it has time to lock on.
Also i forgot to mention that it idles instantly.
maybe 2 maybe 3
ondeath
...
delay(2, function()
-- lock the root part.
end)
My hacky version of this
-- server script StarterCharacterScripts
local debris = game:GetService('Debris')
local character = script.Parent
local player = game.Players:GetPlayerFromCharacter(script.Parent)
local humanoid = character:WaitForChild('Humanoid')
local bodyDisposeTime = 180 -- how long the body stays
humanoid.Died:Connect(function()
if player ~= nil and humanoid ~= nil then
character.Archivable = true
script.Parent = game.ServerScriptService
local cloneChar = character:Clone()
cloneChar.Name = "Deadbody" .. tostring(math.random(1, 10000))
if workspace:FindFirstChild(cloneChar.Name) then
workspace:FindFirstChild(cloneChar.Name):Destroy()
end
task.wait(0.1)
cloneChar.Parent = workspace
local rootPart = cloneChar.HumanoidRootPart or cloneChar.Torso
local clonedHumanoid = cloneChar:FindFirstChildOfClass("Humanoid")
cloneChar:MoveTo(rootPart.Position)
rootPart.Orientation = Vector3.new(90,0,0)
clonedHumanoid.PlatformStand = true
clonedHumanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
clonedHumanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
for i, v in pairs(cloneChar:GetChildren()) do
if v:IsA("BasePart") then
v.Anchored = false
v.CanCollide = false
end
if v:IsA("Script") or v:IsA("LocalScript") then
v:Destroy()
end
end
if cloneChar:FindFirstChild("ForceField") then
cloneChar.ForceField:Destroy()
end
character.Parent = game:GetService("ServerStorage")
debris:AddItem(cloneChar,bodyDisposeTime)
debris:AddItem(script,bodyDisposeTime)
task.wait(1)
if rootPart.Orientation ~= Vector3.new(90,0,0) then
rootPart.Orientation = Vector3.new(0,0,0)
end
task.wait(4)
rootPart.Locked = true
rootPart.Anchored = true
end
end)
Disable BreakJointsOnDeath
property on the humanoid and make sure the humanoid is actually dead.
Chances are that the humanoid thinks it’s still alive and tries to constantly get back up.
You can disable the GettingUp
and Jumping
state to prevent it from standing back up and then set it’s health to 0.
Set the humanoid state to physics or dead
Maybe there’s a way to somehow keep the clothing on a body after deleting the humanoid?
I found out that cloning the character recreates motor 6d contraints inside it. But now I have another issue with constraints, basically when I delete the character the body is very wobbly and it’s physics are freaking out.
That one keeps everything … anything on them. I gave up on that … too hacky.
For corpses in a videro game I typically actually like to literally have a clone of the player somewhere in replicated storage, but with all the motor6ds replaced with ball sockets just to name something (for ragdoll physics).
And when the body is supposed to spawn in, make player invisible, spawn in the body.
And using the ChangeState()
function of the humanoid you can force it into a ragdoll or death state which should make it fall over and keep it’s clothes on (provided you disabled BreakJointsOnDeath
).
Simply make sure any states like jumping and whatnot that can cause a humanoid to get up from a seated/fallen position are also disabled.
Humanoid:ChangeState()
For forcing the humanoid into an state manually.
Humanoid:SetStateEnabled()
For enabling/disabling states so the humanoid stops using them.
Humanoid.BreakJointsOnDeath
Disable this so welds don’t break and hats and clothes don’t fall off.