Cloned character resets collisions

I been trying to create a system where the character ragdoll gets cloned so that a corpse stays even after the player respawn, but for some reason whenever the character is cloned, the clone’s body part collisions turn off, how do i stop this from happening?

video:

here’s the code that handles the corpses:

local players = game:GetService("Players")
local repFirst = game:GetService("ReplicatedFirst")
local ragdoll = require(repFirst.Ragdoll)

players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char.Archivable= true
		
		local humanoid = char:WaitForChild("Humanoid")
		humanoid.BreakJointsOnDeath = false
		humanoid.RequiresNeck = false
		humanoid.Died:Connect(function()	
			
			ragdoll.RagdollCharacter(char)
		end)
	end)
	plr.CharacterRemoving:Connect(function(char)
		local corpse = char:Clone()
		corpse.Parent = workspace
		corpse.Humanoid.EvaluateStateMachine = false
		for _,v in pairs(corpse:GetDescendants()) do
			if v:IsA("Script") or v:IsA("LocalScript") then
				if v.Name ~= "LocalRagdoll" then
					v:Destroy()
				end
			end
		end
		corpse.Name = "Corpse"
		corpse.Humanoid:ChangeState(Enum.HumanoidStateType.Dead)
	end)
end)
1 Like

In the loop before setting the humanoid state to dead, try adding a second if-condition that checks if v is a BasePart and if so, set CanCollide to true

Already tried, but it keep getting set back to false, i even tried setting it every frame using run service but it still keeps getting set to false by something else

Hmm I think I read somewhere that the humanoid is somehow responsible for that but I’m not sure how to fix it. What kind of effect would destroying the humanoid have (after configuring it as appropriate)? Would that unload the character appearance or would that just leave the character appearance and not change it anymore (which would be preferable in this case)?

It unloads any clothing and body color

If you are saying that the parts of the characterModel are having CanCollide off, I think you can use PhysicsService to make it collidable.

local PhysicsService = game:GetService('PhysicsService')
PhysicsService:RegisterCollisionGroup('Collidable')
PhysicsService:CollisionGroupSetCollidable('Collidable', 'Default', true)

for i, v in pairs(character:GetDescendants()) do -- the character is the corpse
    if v:IsA('BasePart') then
        v.CollisionGroup = 'Collidable'
    end
end

I’m not a pro scripter, so I’m not sure this works. But Im sure that you can’t set characterModel’s parts CanCollide property to true or false because humanoid controls parts CanCollide property, so I tried with CollisionGroup, I hope that helped.

I encountered this issue a long time ago. Heres a solution/work-around that may fix your problem.

Try using a for loop and GetChildren() then create a part using Instance.new(“Part”)
and parent it to the limb (which you got from the for i, v in pairs) then set it’s height to just about 1, set its width the same as the limb’s width, create a weld then weld the part to the limb, set it’s transparency to 1, then lastly set it’s massless value to true.

This would create an illusion of the limbs colliding to the ground without actually setting the limb’s collision to true.