BallSocketConstraint Ragdoll not working

Hello, I’m making a ragdoll script that makes the character ragdoll after it dies, all works fine inside the script, the problem is that the ballsocketconstraints, which are created when the character dies, have the active property setted to false and they aren’t working. I can’t find a valid reason to that since I’ve ensured these things:

  • The script works and doesn’t encounter errors
  • The BSCs creation code works
  • The motor6ds are destroyed to make the BSCs work
  • The BSCs are created but their active property is setted to false
  • BreakJointsOnDeath property of said humanoid is default set to false by a script
  • The BSC property Enabled is setted to true by the script
    EDIT: BSC = BallSocketConstraint
3 Likes

Active property is read-only, try putting Enabled property in your BallSocketConstraint creation code, like so:

local BallSocketConstraint = Instance.new("BallSocketConstraint")
BallSocketConstraint.Enabled = true
2 Likes

I do that already, forgot to mention it.

Could you provide more information about the scripts?

1 Like

Result:


Code:

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",
}


local RotationalSettings = {
	Enabled = true,
	LimitsEnabled = true,
	TwistLimitsEnabled = true,
	MaxFrictionTorque = 0,
	Restitution = 0,
	UpperAngle = 0,
	TwistLowerAngle = 45,
	TwistUpperAngle = -45,
}

--//Services\\

local Players = game:GetService("Players")

--//Side Functions\\

function CreateConstraint(Attachment, RotationalSettings)
	local Constraint = Instance.new("BallSocketConstraint")
	
	Constraint.Attachment0 = Attachment
	Constraint.Attachment1 = Attachment
	
	for Key,Value in pairs(RotationalSettings) do
		Constraint[Key] = Value
	end

	Constraint.Parent = Attachment.Parent
	
	return Constraint
end

--//Functions\\

function Ragdollize(Character)
	for i,Limb in pairs(Character:GetChildren()) do
		if Limb:IsA("BasePart") then
			Limb.Anchored = true
		end
	end
	
	for i,Limb in pairs(Character:GetChildren()) do
		if Limbs[Limb.Name] then
			CreateConstraint(Limb[Limbs[Limb.Name]], RotationalSettings)
		end
	end

	for i,v in pairs(Character:GetDescendants()) do 
		if v:IsA("Motor6D") and not (v.Parent.Name == "UpperTorso") then
			v:Destroy()
		end
	end

	for i,Limb in pairs(Character:GetChildren()) do
		if Limb:IsA("BasePart") then
			Limb.Anchored = false
		end
	end
end

Try setting this property of the Humanoid to false:

That might make this work.

Done that already, forgot to mention again, sorry.

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