I am trying to create a ragdoll on death, but now I am getting this error and I cant see where is the problem. It says "“LeftElbow is not a valid member of MeshPart” but, for me, it actually is a child of the part. The error says: “LeftElbow is not a valid member of MeshPart” in line indicated bellow with comment. Note: the error is on the first object iterated by the for loop.
Humanoid.Died:Connect(function()
Shoulder.C1 = DownShoulderCF1
Shoulder.C0 = DownShoulderCF0
-- RAGDOLL
local Clone = Instance.new("Model")
for i, v in pairs (Character:GetDescendants()) do
if v.Name == "Cape" then
v:Destroy()
elseif v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("UnionOperation") and v.Name ~= "HumanoidRootPart" then
v:Clone().Parent = Clone
end
end
for i, v in pairs(Clone:GetDescendants()) do
if v:IsA("Motor6D") then
local w = Instance.new("Attachment")
w.Parent = v.Part0
w.Position = v.C0.Position
w.Name = v.Name
local w2 = Instance.new("Attachment")
w2.Parent = v.Part1
w2.Position = v.C1.Position
w2.Name = v.Name
print("created:", w.Name, "in", w.Parent, w2.Name, "in", w2.Parent)
v:Destroy()
end
end
for i, v in pairs(Clone:GetDescendants()) do
if v:IsA("Attachment") then
if v.Name == "Neck" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.UpperTorso.Neck
w.Attachment1 = Clone.Head.Neck
elseif v.Name == "Waist" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.LowerTorso.Waist
w.Attachment1 = Clone.UpperTorso.Waist
elseif v.Name == "LeftShoulder" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.UpperTorso.LeftShoulder
w.Attachment1 = Clone.LeftUpperArm.LeftShoulder
elseif v.Name == "LeftElbow" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.LeftUpperArm.LeftElbow -- ERROR: LeftElbow is not a valid member of MeshPart
w.Attachment1 = Clone.LeftLowerArm.LeftElbow
elseif v.Name == "LeftWrist" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.LeftLowerArm.LeftWrist
w.Attachment1 = Clone.LeftHand.LeftWrist
elseif v.Name == "RightShoulder" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.UpperTorso.RightShoulder
w.Attachment1 = Clone.RightUpperArm.RightShoulder
elseif v.Name == "RightElbow" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.RightUpperArm.RightElbow
w.Attachment1 = Clone.RightLowerArm.RightElbow
elseif v.Name == "RightWrist" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.RightLowerArm.RightWrist
w.Attachment1 = Clone.RightHand.RightWrist
elseif v.Name == "LeftHip" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.LowerTorso.LeftHip
w.Attachment1 = Clone.RightUpperLeg.LeftHip
elseif v.Name == "LeftKnee" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.LeftUpperLeg.LeftKnee
w.Attachment1 = Clone.LeftLowerLeg.LeftKnee
elseif v.Name == "LeftAnkle" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.LeftLowerLeg.LeftAnkle
w.Attachment1 = Clone.LeftFoot.LeftAnkle
elseif v.Name == "RightHip" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.LowerTorso.RightHip
w.Attachment1 = Clone.RightUpperLeg.RightHip
elseif v.Name == "LeftKnee" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.RightUpperLeg.LeftKnee
w.Attachment1 = Clone.RightLowerLeg.LeftKnee
elseif v.Name == "LeftAnkle" then
local w = Instance.new("BallSocketConstraint")
w.Parent = v.Parent
w.Attachment0 = Clone.RightLowerLeg.LeftAnkle
w.Attachment1 = Clone.RightFoot.LeftAnkle
end
end
end
for i, v in pairs (Character:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("UnionOperation")
or v:IsA("Decal") then
v.Transparency = 1
elseif v:IsA("Tool") then
v.Parent = workspace
elseif v:IsA("Beam") then
v.Transparency = NumberSequence.new(1)
end
end
Clone.Name = "Corpse"
for i, v in pairs(Clone) do
v.Parent = Clone
end
Clone.Parent = workspace
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.