Hello, i am trying to create a ragdoll script for a npc in my game however my script cannot find the attachment points in the model to replace with sockets. I have ConstaintDetails on and the npc works fine. Is this a model problem or something to do with the script?
My code for reference:
local Model = script.Parent.Parent
for _,Part in pairs(Model:GetDescendants()) do
if Part.Name == 'Motor6D' then
print(Part)
local socket = Instance.new("BallSocketConstraint")
local part0 = Part.Part0
local joint_name = Part.Name
local attachment0 = Part.Parent:FindFirstChild(joint_name.."Attachment") or Part.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 = Part.Parent
Part:Destroy()
else
print("nothing found")
end
end
end
