How can I make the player's limbs collide with the enviroment once the character's been ragdolled?

Hi I recently casually made a pretty simple ragdolling script that just disabled all of the player’s Motor6d’s and enabled all of the SocketConstraints I’ve put in my custom StarterCharacter


The SocketConstraints all have Att1 & Att2 set as a default roblox rig attachment except for the legs that use “LeftWaistAtt” and “RightWaistAtt” i don’t really know if that matters with the problem I’m having

-- Script in ServerScriptService
local replicatedstorage = game:GetService("ReplicatedStorage")
local ragdoll = replicatedstorage:WaitForChild("rdoll")


ragdoll.OnServerEvent:Connect(function(plr,bool)
	
	plr.Character:FindFirstChildOfClass("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Physics,bool)
	if bool then
		plr.Character:FindFirstChildOfClass("Humanoid"):ChangeState(Enum.HumanoidStateType.Ragdoll)
	else
		plr.Character:FindFirstChildOfClass("Humanoid"):ChangeState(Enum.HumanoidStateType.None)
	end
	
	plr.Character:FindFirstChildOfClass("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
	
	plr.Character:FindFirstChildOfClass("Humanoid").PlatformStand = bool
	
	--if bool then
	--	plr.Character:FindFirstChildOfClass("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Physics,true)
	--else
	--	plr.Character:FindFirstChildOfClass("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Jumping,true)
	--end
	
	
	
	for i,v in pairs(plr.Character:GetDescendants()) do
		
		if v:IsA("BallSocketConstraint") then
			if bool then
				v.Enabled = true
			else
				v.Enabled = false
			end			
		end
		if v:IsA("Motor6D") then
			if bool then
				if v.Parent.Name == "HumanoidRootPart" then return end
				v.Enabled = false
			else
				v.Enabled = true
			end	
		end
		
	end
	
end)

-- LocalScript in StarterCharacterScripts that triggers the Server Script
local replicatedstorage = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")

local ragdoll = replicatedstorage:WaitForChild("rdoll")

local canrag = true

uis.InputBegan:Connect(function(input)
	
	if input.KeyCode == Enum.KeyCode.R then
		
		print("dolled")
		ragdoll:FireServer(canrag)
		
		if canrag then
			canrag = false
		else
			canrag = true
		end
		
	end
	
end)

While the script works pretty well (for my standards :wink:) the limbs of the character flop and don’t collide with the ground once the character is ragdolled

immagine

I’m aware that certain named parts aren’t affected by collision when they’re under a humanoid but I don’t know if changing the limbs’ names is a great way of solving this problem considering some animations get screwed

I’ve tried looking around for awnsers but I didn’t really get far since most of them either lead to deprecated codes or just linked to really complex ragdoll modules that I didn’t really need

My end goal is to make a ragdoll system similar to the one seen in Item Asylum where players get stunned and knocked back while ragdolling once they’ve been hit
ps. I don’t really know if I should’ve specified this but I know my code isn’t compatible with r15 im just trying to make it available for r6

Using code, you should loop through all parts in the player and set CanCollide to true
You will need to loop through them again and make them CanCollide false when they exit ragdoll

		if v:IsA("BasePart") then
			if bool then
				if v.Name == "HumanoidRootPart" then return end
				v.CanCollide = true
			else
				if v.Name == "HumanoidRootPart" then return end
				v.CanCollide = false
			end	
		end

immagine
Nope, still as floppy as ever

As I’ve mentioned before the collision system also has something to do with the naming of the limbs in a character that has a humanoid (for example if I were to put a BasePart named “awpdjapodjpoajd” in the character I’d have full control of what would be going on with the Collision bool)

I’ve also tried giving the limbs their own CollisionGroup once the character ragdolled but that didn’t seem to change anything

Just realised you’ve been using return within it when it gets to the humanoid root part - return will exit the function, but all you want to do is continue to the next item

if you didn't catch the hint:

(replace return with continue)

I don’t quite get what you mean could you provide a code snippet if possible

			if bool then	
				
				if v.Name ~= "HumanoidRootPart" then 
					v.CanCollide = true
				end
				
			else
				if v.Name ~= "HumanoidRootPart" then 
					v.CanCollide = false
				end
			end	
		end

idk if you mean like this (in wich case it still dosen’t work)