So, i want to make a ragdoll without the player dying first. but then this happen
The issue is, the ragdoll went flying, i don’t know why that happen
i searched the devforum, but didn’t found anything related to this, so im asking on how to fix it?
Video Proof: https://youtu.be/V0Qlz1A-H0I
Codes :
local character2 = script.Parent
character2.ChildRemoved:Connect(function(child)
if not character2:FindFirstChild(“Ragdoll”) then
for i,v in pairs(workspace:GetChildren()) do
if v.Name == character2.Name…“Ragdoll” then
character2.Humanoid.Health = v.Humanoid.Health
character2:SetPrimaryPartCFrame(v.PrimaryPart.CFrame)
character2.PrimaryPart.Anchored = false
v:Destroy()
local resetcam = game.ReplicatedStorage.ResetCam:Clone()
resetcam.Parent = character2
game.Debris:AddItem(resetcam,0.1)
end
end
end
end)
character2.ChildAdded:Connect(function(child)
if child.Name == “Ragdoll” and not workspace:FindFirstChild(character2.Name…“Ragdoll”) then
local humanoid = character2:Clone()
humanoid:FindFirstChild(“RagdollScriptLife”):Destroy()
humanoid:SetPrimaryPartCFrame(character2.PrimaryPart.CFrame)
humanoid.Name = character2.Name…“Ragdoll”
humanoid.Parent = workspace
for i,v in pairs(humanoid:GetChildren()) do
if v:IsA(“Part”) or v:IsA(“MeshPart”) or v:IsA(“UnionOperation”) then
v.Anchored = false
end
end
character2.PrimaryPart.Anchored = true
character2:SetPrimaryPartCFrame(character2.PrimaryPart.CFrame * CFrame.new(0,100000,0))
local character = humanoid
character.Humanoid.Health = character2.Humanoid.Health
character.Humanoid.BreakJointsOnDeath = false
local d = character:GetDescendants()
for i=1,#d do
local desc = d[i]
if desc:IsA(“Motor6D”) then
local socket = Instance.new(“BallSocketConstraint”)
local part0 = desc.Part0
local joint_name = desc.Name
local attachment0 = desc.Parent:FindFirstChild(joint_name…“Attachment”) or desc.Parent:FindFirstChild(joint_name…“RigAttachment”)
local attachment1 = part0:FindFirstChild(joint_name…“Attachment”) or part0:FindFirstChild(joint_name…“RigAttachment”)
if attachment0 and attachment1 then
socket.Attachment0, socket.Attachment1 = attachment0, attachment1
socket.Parent = desc.Parent
desc:Destroy()
end
end
end
for i,v in pairs(character:GetDescendants()) do
if v:IsA(“Motor6D”) then
v:Destroy()
end
end
end
end)