Hey! I saw someone else post the same issue 3 years ago, but he had no replies.
The post is called “Ragdoll script not working with character clones?”
Any reason why when I clone Character, the new ragdoll corpse stays standing? No replication issues.
I do notice that the HumanoidRootPart separates from the rest of the corpse.
-- On Death
local function OnDeath()
if DeathDebounce then return end
DeathDebounce = true
Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
Character.Archivable = true
for i, v in pairs(Character:GetDescendants()) do
if v:IsA("BasePart") then
v:SetNetworkOwner(nil)
v.CanCollide = true
end
end
-- Ragdoll
Ragdoll(Character, Humanoid)
task.wait(RespawnTime) -- Wait Respawn Time
-- Create Corpse
if Character.PrimaryPart then
local Corpse = Character:Clone()
local CorpseHead = Corpse:FindFirstChild("Head")
Corpse.Name = Character.Name.."-Corpse"
if CorpseHead then
CorpseHead.CanCollide = true
end
Corpse.Parent = workspace
end
-- Make Sure Player Character doesn't Load Twice in a Row
if not Player.Character or Player.Character:WaitForChild("Humanoid").Health <= 0 then
Player:LoadCharacter()
end
end
Humanoid.Died:Connect(OnDeath)
Actually the HumanoidRootParts are not separated on client or server. I think that was before when I tried ragdolling the corpse without ragdolling the character.
Here is Module of Ragdoll. This is the one used by Roblox in NPC’s like “NP-C 9000 Robots”
local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")
local RigTypes = require(script.RigTypes)
local RAGDOLLED_TAG = "__Ragdoll_Active"
local function ragdoll(model, humanoid)
assert(humanoid:IsDescendantOf(model))
if CollectionService:HasTag(model, RAGDOLLED_TAG) then
return
end
CollectionService:AddTag(model, RAGDOLLED_TAG)
-- Turn into loose body:
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
-- Instantiate BallSocketConstraints:
local attachments = RigTypes.getAttachments(model, humanoid.RigType)
for name, objects in pairs(attachments) do
local parent = model:FindFirstChild(name)
if parent then
local constraint = Instance.new("BallSocketConstraint")
constraint.Name = "RagdollBallSocketConstraint"
constraint.Attachment0 = objects.attachment0
constraint.Attachment1 = objects.attachment1
constraint.LimitsEnabled = true
constraint.UpperAngle = objects.limits.UpperAngle
constraint.TwistLimitsEnabled = true
constraint.TwistLowerAngle = objects.limits.TwistLowerAngle
constraint.TwistUpperAngle = objects.limits.TwistUpperAngle
constraint.Parent = parent
end
end
-- Instantiate NoCollisionConstraints:
local parts = RigTypes.getNoCollisions(model, humanoid.RigType)
for _, objects in pairs(parts) do
local constraint = Instance.new("NoCollisionConstraint")
constraint.Name = "RagdollNoCollisionConstraint"
constraint.Part0 = objects[1]
constraint.Part1 = objects[2]
constraint.Parent = objects[1]
end
-- Destroy all regular joints:
for _, motor in pairs(model:GetDescendants()) do
if motor:IsA("Motor6D") then
motor:Destroy()
end
end
end
return ragdoll
Strange how it’s not positioning itself at the character’s exact position (possibly due to the server assuming that the character is in a different place).
Anyways, have you attempted to set the Corpse’s position to the character’s position and anchoring its HumanoidRootPart?
that could work. I mean if I clone a corpse of character, then it should have the exact location of the character. I wouldn’t want to anchor the ragdoll, since i want them to be able to be interacted.
i think it has something to do with the corpse still having some link with the players character, that’s why it is standing. Ima try to figure out this link between clone and player character.
Either that, or change your Ragdoll’s HumanoidStateType to Physics, since PlatformStand will cause the limbs to fall through the ground (that is, if your ragdoll doesn’t use collision parts).
before parenting to workspace and after parenting to workspace.
Instead of making an interactive ragdoll, I just made them noncollidable and anchored:
local Corpse = Character:Clone()
Corpse.Name = Character.Name.."-Corpse"
-- Anchor Corpse
for i, v in pairs(Corpse:GetDescendants()) do
if v:IsA("Script") then
v:Destroy()
elseif v:IsA("BasePart") then
v.Anchored = true
v.CanCollide = false
v.CollisionGroup = "IgnorePlayer"
end
end
Corpse.Parent = workspace
This sucks that they can’t be interactive but it is what it is!