It doesn’t work in your script because your script doesn’t iterate through the bodyparts and set cancollide to true. it only sets the parent o the attachments to cancollide true.
Roblox humanoid characters have their limbs set to CanCollide = false every frame. This is intended behaviour, just how humanoids work.
I’m pretty sure, like 70% sure that if you set the Humanoid.StateType to Physics, it stops the engine from automatically overriding any properties you set, so setting CanCollide should work then. Haven’t touched the state in a while though so I honestly might’ve forgotten.
If that doesn’t work, you could always weld a part to each limb that acts as the collision piece.
thanks. i solved it. I defined a ragdolled bool and set it to false. then when ragdoll state is enabled it’s set to true. while it’s set to true, set cancollide to true.
not sure if this is the best way to do it. (runService possibly?)
Edit:
instead of using a while loop to constantly set it to true, I used RunService to do it more efficiently.
It’s the case for limbs too. Peep the Roblox announcement below.
I was partially wrong, in that they changed it so that instead of having it set every frame, it’s set every state change. But doesn’t matter, humanoids still get their limb collisions reset automatically, causing the problem OP had.
Hence why setting the humanoid state to one that doesn’t automatically switch, like Physics, would fix this. Also why OP’s solution works, as setting collision on only after the state is changed to ragdoll won’t have it automatically negate.