R6 ragdolls work fine but R15 ragdolls have seizures and panick attacks

Hello everyone! I’ve written ragdoll script for different rigs, and I noticed that R6 rigs work perfectly fine, while R15 rigs have different seizures.
Here’s the script I’m using
(script has some garbage since initially I took another script)

local module = {}
--CONFIGURATION
local ragdoll_parent = Instance.new("Folder",workspace)
ragdoll_parent.Name = "ragdoll_folder"
local HideNickname = true -- sets name and health display distance to 0


module.Check = function(t)
	for _,v in pairs({"LeftWrist","RightWrist","LeftAnkle","RightAnkle"}) do
		if v == t then return false end
	end
	return true
end


function module.Ragdoll(model: Model): "Turns Model into a ragdoll"
	-- Humanoid configuration
	local H = model:FindFirstChildWhichIsA("Humanoid") :: Humanoid
	H:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
	H:SetStateEnabled(Enum.HumanoidStateType.FallingDown,false)
	H:SetStateEnabled(Enum.HumanoidStateType.Dead,false)
	H:SetStateEnabled(Enum.HumanoidStateType.Ragdoll,true)
	--H.NameDisplayDistance=0
	if HideNickname then
		H.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
		H.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
	end
	H.BreakJointsOnDeath = false
	H.RequiresNeck = false
	for _,v in pairs(H:GetPlayingAnimationTracks())do v:Stop(0)end
	if model:FindFirstChild("Animate") then
		model.Animate.Disabled = true
	end
	-- loop through models descendants to create ball socckets and configure collisions
	for _,v in pairs(model:GetDescendants()) do
		if v:IsA("Motor6D") then -- and module.Check(v.Name)
			local ball_socket = Instance.new("BallSocketConstraint",v.Parent)
			local a0,a1 = Instance.new("Attachment"),Instance.new("Attachment")
			local part0, part1 = v.Part0,v.Part1
			a0.Parent,a1.Parent = part0, part1
			ball_socket.Attachment0,ball_socket.Attachment1 = a0,a1
			a0.CFrame,a1.CFrame = v.c0,v.c1
			ball_socket.LimitsEnabled = true
			ball_socket.TwistLimitsEnabled = true
			ball_socket.Enabled = true
			v.Enabled=false
			-- create no collision constraint to stop parts from colliding
			local no_coll_const = Instance.new("NoCollisionConstraint",v.Parent)
			no_coll_const.Part0=part0
			no_coll_const.Part1=part1
			no_coll_const.Enabled=true
		end
	end

	H:ChangeState(Enum.HumanoidStateType.Ragdoll)
	model.Parent=ragdoll_parent
end

function module.Unragdoll(model: Model): "Unragdolls the provided model"
	-- loop through models descendants to destroy ball socckets and re-enable joints
	for _,v in pairs(model:GetDescendants()) do
		if v:IsA("BallSocketConstraint") then
			v:Destroy()
		elseif v:IsA("Motor6D") then
			v.Enabled=true
		end
	end
	-- Humanoid configuration
	local H = model:FindFirstChildWhichIsA("Humanoid") :: Humanoid
	H:SetStateEnabled(Enum.HumanoidStateType.GettingUp,true)
	H:SetStateEnabled(Enum.HumanoidStateType.FallingDown,true)
	H:SetStateEnabled(Enum.HumanoidStateType.Dead,true)
	H:SetStateEnabled(Enum.HumanoidStateType.Ragdoll,true)
	if HideNickname then
		H.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.Viewer
		H.HealthDisplayType = Enum.HumanoidHealthDisplayType.DisplayWhenDamaged
	end
	H.BreakJointsOnDeath = true
	H.RequiresNeck = true
end

return module

also the example

Okay so, after experimenting with ball socket, I fixed the issue.
Changing the BallSocketConstraint.MaxFrictionTorque and BallSocketConstraint.UpperAngle stopped the unreasonable seizures. To be specific, the values were these:

ball_socket.MaxFrictionTorque=100
ball_socket.UpperAngle=30

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.