#Help me script please

1 messages · Page 1 of 1 (latest)

past tulip
#

function RagdollModule.Recover(character)
if not character or not savedJoints[character] then return end

local humanoid = character:FindFirstChildOfClass("Humanoid")

task.wait(0.1)

for _, jointData in pairs(savedJoints[character]) do
    -- Verify parts still exist
    if jointData.Part0 and jointData.Part1 and jointData.Parent then
        local newJoint = Instance.new("Motor6D")
        newJoint.Name = jointData.Name
        newJoint.Part0 = jointData.Part0
        newJoint.Part1 = jointData.Part1
        newJoint.C0 = jointData.C0
        newJoint.C1 = jointData.C1
        newJoint.Parent = jointData.Parent
    end
end

if humanoid then
    humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end

savedJoints[character] = nil

end

the problem is that they move freely

ocean widget
#

function RagdollModule.Recover(character)
if not character or not savedJoints[character] then return end

local humanoid = character:FindFirstChildOfClass("Humanoid")

-- Wait a tiny bit to ensure all ragdoll constraints are cleaned up
task.wait(0.1)

-- Remove all ragdoll constraints (BallSocketConstraints, HingeConstraints, etc.)
for _, descendant in ipairs(character:GetDescendants()) do
    if descendant:IsA("BallSocketConstraint") or descendant:IsA("HingeConstraint") or descendant:IsA("NoCollisionConstraint") then
        descendant:Destroy()
    end
end

-- Recreate Motor6Ds
for _, jointData in pairs(savedJoints[character]) do
    if jointData.Part0 and jointData.Part1 and jointData.Parent then
        local newJoint = Instance.new("Motor6D")
        newJoint.Name = jointData.Name
        newJoint.Part0 = jointData.Part0
        newJoint.Part1 = jointData.Part1
        newJoint.C0 = jointData.C0
        newJoint.C1 = jointData.C1
        newJoint.Parent = jointData.Parent
    end
end

-- Re-enable collisions between limbs and torso (sometimes turned off in ragdoll)
for _, part in ipairs(character:GetDescendants()) do
    if part:IsA("BasePart") then
        part.Anchored = false
        part.Massless = false
        part.CanCollide = true
    end
end

-- Restore humanoid control
if humanoid then
    humanoid.PlatformStand = false
    humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
    humanoid:BuildRigFromAttachments() -- rebuilds internal rig hierarchy
end

-- Clear saved joint data
savedJoints[character] = nil

end