You could do something like this, I don’t think you need to clone the player. If you do you can simply clone the players Character.
local function CreateRagdoll(character)
local character = character:Clone(); character.Parent = workspace
for _, Joint in pairs(character:GetDescendants()) do
if Joint:IsA("Motor6D") then
local Socket = Instance.new("BallSocketConstraint")
local a1, a2 = Instance.new("Attachment")
a1.Parent = Joint.Part0; a2.Parent = Joint.Part1
Socket.Parent = Joint.Parent
Socket.Attachment0 = a1; Socket.Attachment1 = a2
a1.CFrame = Joint.C0; a2.CFrame = Joint.C1
Socket.LimitesEnabled = true
Socket.TwistLimitsEnabled = true
end
end
end
This is for the Ragdoll, the clone is optional, remove it if you don’t need it. Link this to Humanoid.Died and make sure to change the respawn time so you don’t get respawned. Hope this helps.
Edit: You may need to add this:
game:GetService("Players").PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local Humanoid = char:WaitForChild("Humanoid")
Humanoid.BreakJointsOnDeath = false -- This line
Humanoid.Died:Connect(function()
CreateRagdoll(char)
end)
end
end
What’s happening here is the characters state called Getting Up is firing, I think what you can do is change the state to physics I believe Humanoid:ChangeState(Enum.HumanoidStateType.Physics).
local function ConnectLimbs(char)
for i, limb in pairs(char:GetChildren()) do
if limb:IsA("BasePart") then
local atch0, atch1, atch2, atch3, atch4, atch5
if limb.Name == "Head" then
atch0 = char.Head.NeckRigAttachment
atch1 = char.UpperTorso.NeckRigAttachment
elseif limb.Name == "UpperTorso" then
atch0 = char.UpperTorso.WaistRigAttachment
atch1 = char.LowerTorso.WaistRigAttachment
atch2 = char.UpperTorso.LeftShoulderRigAttachment
atch3 = char.LeftUpperArm.LeftShoulderRigAttachment
atch4 = char.UpperTorso.RightShoulderRigAttachment
atch5 = char.RightUpperArm.RightShoulderRigAttachment
elseif limb.Name == "LowerTorso" then
atch0 = char.LowerTorso.LeftHipRigAttachment
atch1 = char.LeftUpperLeg.LeftHipRigAttachment
atch2 = char.LowerTorso.RightHipRigAttachment
atch3 = char.RightUpperLeg.RightHipRigAttachment
elseif limb.Name == "LeftUpperLeg" then
atch0 = char.LeftUpperLeg.LeftKneeRigAttachment
atch1 = char.LeftLowerLeg.LeftKneeRigAttachment
elseif limb.Name == "RightUpperLeg" then
atch0 = char.RightUpperLeg.RightKneeRigAttachment
atch1 = char.RightLowerLeg.RightKneeRigAttachment
elseif limb.Name == "LeftLowerLeg" then
atch0 = char.LeftLowerLeg.LeftAnkleRigAttachment
atch1 = char.LeftFoot.LeftAnkleRigAttachment
elseif limb.Name == "RightLowerLeg" then
atch0 = char.RightLowerLeg.RightAnkleRigAttachment
atch1 = char.RightFoot.RightAnkleRigAttachment
elseif limb.Name == "LeftUpperArm" then
atch0 = char.LeftUpperArm.LeftElbowRigAttachment
atch1 = char.LeftLowerArm.LeftElbowRigAttachment
elseif limb.Name == "RightUpperArm" then
atch0 = char.RightUpperArm.RightElbowRigAttachment
atch1 = char.RightLowerArm.RightElbowRigAttachment
elseif limb.Name == "LeftLowerArm" then
atch0 = char.LeftLowerArm.LeftWristRigAttachment
atch1 = char.LeftHand.LeftWristRigAttachment
elseif limb.Name == "RightLowerArm" then
atch0 = char.RightLowerArm.RightWristRigAttachment
atch1 = char.RightHand.RightWristRigAttachment
end
if atch0 and atch1 then
local ballInSocket = Instance.new("BallSocketConstraint", limb)
ballInSocket.Attachment0 = atch0
ballInSocket.Attachment1 = atch1
end
if atch2 and atch3 then
local ballInSocket = Instance.new("BallSocketConstraint", limb)
ballInSocket.Attachment0 = atch2
ballInSocket.Attachment1 = atch3
end
if atch4 and atch5 then
local ballInSocket = Instance.new("BallSocketConstraint", limb)
ballInSocket.Attachment0 = atch4
ballInSocket.Attachment1 = atch5
end
elseif limb:IsA("Accessory") then
local h = limb:FindFirstChild("Handle")
if h then
local part0 = char.Head
local atch = h:FindFirstChildOfClass("Attachment")
if atch.Name == "HatAttachment" or atch.Name == "FaceFrontAttachment" then
part0 = char.Head
end
local ap = Instance.new("AlignPosition", part0)
if part0 == char.Head then
ap.Attachment1 = char.Head:FindFirstChild(atch.Name)
ap.Attachment0 = atch
ap.RigidityEnabled = true
ap.Responsiveness = 200
end
local ao = Instance.new("AlignOrientation", part0)
if part0 == char.Head then
ao.Attachment1 = char.Head:FindFirstChild(atch.Name)
ao.Attachment0 = atch
ao.RigidityEnabled = true
ao.Responsiveness = 200
end
end
end
end
end
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
Character:WaitForChild("Humanoid").Died:Connect(function()
ConnectLimbs(Character)
local test = (Character:GetChildren())
local testing = Instance.new("Model",workspace)
for i = 1, #test do
local child = test[i]
child:Clone()
child.Parent = testing
end
end)
end)
end)
But for some reason it doesn’t copy the player model
You could look into DebrisService, this will help your current problem or you could just add a wait(300) maybe since, even if the player leaves it the cloned model would still be there.
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
Character:WaitForChild("Humanoid").Died:Connect(function()
ConnectLimbs(Character)
game:GetService("Debris"):AddItem(Character, 300)
local test = (Character:GetChildren())
local testing = Instance.new("Model",workspace)
for i = 1, #test do
local child = test[i]
child:Clone().Parent = testing
end
end)
end)
end)
local function ConnectLimbs(char)
char = char:Clone()
char.Parent = workspace
game:GetService("Debris"):AddItem(char, 300)
for i, limb in pairs(char:GetChildren()) do
if limb:IsA("BasePart") then
char.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None char.Humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
This should work.