Corpse limbs keep being uncollided even after setting their CanCollide to true

I want the corpse to ragdoll but the limbs keep clipping.

I tried setting their CanCollide to true but didnt seem to work

local Players = game:GetService("Players")
local humanoid = script.Parent:WaitForChild("Humanoid")
local ReplicatedStorage = game:GetService("ReplicatedStorage")


humanoid.BreakJointsOnDeath = false

humanoid.Died:Connect(function()

	for _, joint in ipairs(script.Parent:GetDescendants()) do
		if joint:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local a1 = Instance.new("Attachment")
			local a2 = Instance.new("Attachment")

			a1.Parent = joint.Part0
			a2.Parent = joint.Part1

			socket.Parent = joint.Parent
			socket.Attachment0 = a1
			socket.Attachment1 = a2
			a1.CFrame = joint.C0
			a2.CFrame = joint.C1
			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true

			joint:Destroy()
		end
	end

	task.wait(Players.RespawnTime)


	script.Parent.Archivable = true
	local ragdoll = script.Parent:Clone()
	ragdoll.Humanoid.PlatformStand = true


	for _, d in ipairs(ragdoll:GetDescendants()) do
		if d:IsA("Script") or d:IsA("LocalScript") then
			d:Destroy()
		elseif d:IsA("Humanoid") and d:FindFirstChild("Animator") then
			d.Animator:Destroy()
		elseif d:IsA("StringValue") or d:IsA("BoolValue") or d:IsA("IntValue") or d:IsA("ObjectValue") then
			d:Destroy()
		end
	end
	




	if ragdoll:FindFirstChild("Health") then
		ragdoll.Health:Destroy()
	end


	ragdoll.Parent = workspace:WaitForChild("PlrCorpses")
	for _, part in ipairs(ragdoll:GetDescendants()) do
		if part:IsA("BasePart") and table.find({"Head", "Torso", "Left Arm", "Left Leg", "Right Arm", "Right Leg"}, part.Name) then
			part.CanCollide = true
		end
	end
	



	local plr = Players:FindFirstChild(humanoid.Parent.Name)

	local tempFolder = Instance.new("Folder")
	tempFolder.Name = "Loot_" .. math.random(1,99999999)
	tempFolder.Parent = ReplicatedStorage
	
	ragdoll:AddTag("Lootable")
	ragdoll:SetAttribute("Loot", tempFolder.Name)

	local plr = Players:FindFirstChild(humanoid.Parent.Name)
	if plr then

		local toolContainers = {ReplicatedStorage:WaitForChild("items"), ReplicatedStorage:WaitForChild("weapons_tools")}
		for _, container in ipairs(toolContainers) do
			for _, tool in ipairs(container:GetChildren()) do

				local hadTool = plr.Backpack:FindFirstChild(tool.Name) or plr.Character:FindFirstChild(tool.Name)
				if hadTool then
					local toolClone = tool:Clone()
					toolClone.Parent = tempFolder

					local durability = hadTool:FindFirstChild("durability")
					if durability then
						if not toolClone:FindFirstChild("durability") then
							local newDur = Instance.new(durability.ClassName)
							newDur.Name = "durability"
							newDur.Value = durability.Value
							newDur.Parent = toolClone
						else
							toolClone.durability.Value = durability.Value
						end
					end
				end
			end
		end


		plr.Emo.Value = 0
		plr.EmoLevel.Value = 0
	end
end)

any help is appreciated.

That how humanoids work.
It always makes limb can collide false exeption being Physics and Ragdoll state afaik.
You need to change humanoid state first.

Also please dont use ipairs/pairs cause they are always slower than generic iteration (i tested)
for i,v in {} do end is a lot more clear and faster and preserves ipairs behavior if possible.

2 Likes

thanks for telling me that, works now.

1 Like

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