As you had your code setup, the Attachment settings for the Constraint would only go to the same RigAttachment, so basically the constraints were setup for the one part, and thus your character would just fall to pieces. My change to your code is a new function that takes the settings of each Motor6D and uses the Part1 to determine the RigAttachment to use for Attachment1, then creates an arbitrary new Attachment and parents it to the Part0 … I think I might use this, if I don’t get the other ragdoll scripts to work. One that looks good is in the new Roblox Weapons System library folder named “Ragdoll”, which is quite a bit more sophisticated, but this is quick and simple.
NOTE: The end result isn’t pretty… I think I might add a second reference to your Limbs table to specify the part and existing attachment that should be used for Attachment0.
local Limbs = {
['LeftFoot'] = 'LeftAnkleRigAttachment',
["LeftHand"] = "LeftWristRigAttachment",
["LeftLowerArm"] = "LeftElbowRigAttachment",
["LeftLowerLeg"] = "LeftKneeRigAttachment",
["LeftUpperArm"] = "LeftShoulderRigAttachment",
["LeftUpperLeg"] = "LeftHipRigAttachment",
["LowerTorso"] = "WaistRigAttachment",
["RightFoot"] = "RightAnkleRigAttachment",
["RightHand"] = "RightWristRigAttachment",
["RightLowerArm"] = "RightElbowRigAttachment",
["RightLowerLeg"] = "RightKneeRigAttachment",
["RightUpperArm"] = "RightShoulderRigAttachment",
["RightUpperLeg"] = "RightKneeRigAttachment",
["Head"] = "NeckRigAttachment",
}
--//Services\\
local RotationalSettings = {
Enabled = true,
LimitsEnabled = true,
TwistLimitsEnabled = true,
MaxFrictionTorque = 0,
Restitution = 0,
UpperAngle = 0,
TwistLowerAngle = 45,
TwistUpperAngle = -45,
}
local Players = game:GetService("Players")
--//Side Functions\\
local function CreateConstraint(Attachment0,Attachment1, RotationalSettings)
local Constraint = Instance.new("BallSocketConstraint")
Constraint.Attachment0 = Attachment0
Constraint.Attachment1 = Attachment1
for Key,Value in pairs(RotationalSettings) do
Constraint[Key] = Value
end
Constraint.Parent = Attachment1.Parent
return Constraint
end
local function SetupContraintFromMotorSettings(Motor, RotationalSettings)
local Constraint = Instance.new("BallSocketConstraint")
Constraint.Attachment0 = Instance.new("Attachment",Motor.Part0)
Constraint.Attachment0.Name = Motor.Part0.Name.."NEWAttachment" --Motor.Parent:FindFirstChild(Motor.Part0.Name.."Attachment")
Constraint.Attachment1 = Motor.Parent:FindFirstChild(Motor.Name.."RigAttachment")
for Key,Value in pairs(RotationalSettings) do
Constraint[Key] = Value
end
Constraint.Parent = Motor.Parent
Constraint.Name = Motor.Name.."Constraint"
return Constraint
end
--//Functions\\
local function Ragdollize(Character)
for i,Limb in pairs(Character:GetChildren()) do
if Limb:IsA("BasePart") then
--Limb.Anchored = true
end
end
for i,v in pairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
--CreateConstraint(Limb[Limbs[Limb.Name]], RotationalSettings)
SetupContraintFromMotorSettings(v,RotationalSettings)
end
end
for i,v in pairs(Character:GetDescendants()) do
if (v:IsA("Motor6D") or v:IsA("Motor")) then -- and not (v.Parent.Name:find("Torso")) then
v:Destroy()
end
end
for i,Limb in pairs(Character:GetChildren()) do
if Limb:IsA("BasePart") then
-- Limb.Anchored = false
end
end
end