I want to reset a ragdolled player after they take damage (so they don't stay ragdolled forever). I have this ragdoll function, so I was wondering how I can use the code already inside the function to reset the ragdoll (like modding the code)
local function Ragdoll()
for i, joint in pairs(script.Parent:GetDescendants()) do
if joint:IsA("Motor6D") then
local newSocket = Instance.new("BallSocketConstraint")
local a1 = Instance.new('Attachment')
local a2 = Instance.new('Attachment')
a1.Parent = joint.Part0
a2.Parent = joint.Part1
newSocket.Parent = joint.Parent
newSocket.Attachment0 = a1
newSocket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
newSocket.LimitsEnabled = true
newSocket.TwistLimitsEnabled = true
joint:Destroy()
end
end
end
