Ragdolls sometimes lose their limbs

Hello, I have created an R6 toggable ragdoll script, and for the most part it works fine, sometimes however the ragdolls explode, I’m sure this is because I’m using the glue object to ragdoll them instead of the newer constraints, however since I have no experience with new constraints, I don’t know how to convert them to use newer constraints. I don’t know what types of constraints to use.

Here is the script: ragdollhandler.lua (3.7 KB)