R6 Ragdolls: Tools malfunctioning after unragdolling

Hi all,
So I’ve been trying to implement an R6 ragdoll system into one of my projects, and I recently discovered Gusshiy’s solution: How can i make a "R to Ragdoll" script? - #3 by Gusshiy

I’ve adapted Gusshiy’s system and modified it to accompany my own game’s systems slightly more, however I’ve come to a problem involving the ragdoll: If a player is ragdolled while a tool is equipped, their tool will fall out of their hands and wobble on the floor forever. The tool remains equipped, it just is no longer on the hand ,but the floor.

I noticed that the RightGrip weld on the character’s Right Arm is destroyed once the ragdoll is over, so the first thing I tried was the obvious answer; remake the weld. However, this didn’t work and created more issues, such as the player character walking with spinning parts.

I guess my question is, what steps could I take to modify this ragdoll system in a way such that tools do not leave the player’s hand? I’ve been struggling with this issue for awhile now, so any advice or ideas are appreciated.

Here’s the code I’m currently working with; again, 99% of this is written by Gusshiy and I’ve simply modified it slightly to accompany my game more.

local ragdollModule = {}
local RagdollEvent = game.ReplicatedStorage.Events.RagdollClient
local Players = game:GetService("Players")
function ragdollModule.Ragdoll(Character, bool)
	local ply = Players:GetPlayerFromCharacter(Character)
	if bool then
		for i,v in pairs(Character:GetDescendants()) do
			if v:IsA("Motor6D") and v.Parent.Name ~= "HumanoidRootPart" then
				local Socket = Instance.new("BallSocketConstraint")
				local a1 = Instance.new("Attachment")
				local a2 = Instance.new("Attachment")
				a1.Parent = v.Part0
				a2.Parent = v.Part1
				Socket.Parent = v.Parent
				Socket.Attachment0 = a1
				Socket.Attachment1 = a2
				a1.CFrame = v.C0
				a2.CFrame = v.C1
				Socket.LimitsEnabled = true
				Socket.TwistLimitsEnabled = true
				v:Destroy()
			end
		end
		Character.Humanoid.RequiresNeck = false
		Character.Humanoid.Sit = true
		if not Character:FindFirstChild("isRagdoll") then
			local val = Instance.new("Folder")
			val.Name = "isRagdoll"
			val.Parent = Character
		end
		if ply then
			RagdollEvent:FireClient(ply, bool)
		else
			Character.Humanoid:ChangeState("Physics")
		end
	else
		for i,v in pairs(Character:GetDescendants()) do
			if v:IsA("BallSocketConstraint") then
				v.UpperAngle = 0
				v.TwistUpperAngle = 0
				v.TwistLowerAngle = 0
				local Joints = Instance.new("Motor6D",v.Parent)
				Joints.Part0 = v.Attachment0.Parent
				Joints.Part1 = v.Attachment1.Parent
				Joints.C0 = v.Attachment0.CFrame
				Joints.C1 = v.Attachment1.CFrame
				v:Destroy()
			end
			
		end
		Character.Humanoid.Sit = false
		local val = Character:FindFirstChild("isRagdoll")
		if val then
			val:Destroy()
		end
		
		if ply then
			RagdollEvent:FireClient(ply, bool)
		else
			Character.Humanoid:ChangeState("PlatformStanding")
		end
	end
end

return ragdollModule
3 Likes

Update for anyone else that’s been searching and had this issue, as the fix turned out to be simple!:

This issue is solved by simply disabling the Motor6Ds rather then destroying them
So with the earlier code, it’d just be:
v.Enabled = false for enabling ragdoll
v.Enabled = true for disabling ragdoll

Hope anyone that also stumbles upon this issue sees this solution, as it was really annoying to deal with

12 Likes