Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Need help making my ragdoll and unragdoll script, unragdoll doesn't work as well?

Asked by 4 years ago
Edited 4 years ago

Heyo! Today I am making a R to ragdoll thing but I can't seem to make the unragdoll work and the ragdoll floats up instead of having gravity.

Sorry for the dogey title, had to add a question mark.

Here is the death script:

local function ragdoll(c)
    for _, v in pairs(c:GetDescendants()) do
        if v:IsA("Motor6D") then
            local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
            a0.CFrame = v.C0
            a1.CFrame = v.C1
            a0.Parent = v.Part0
            a1.Parent = v.Part1

            local b = Instance.new("BallSocketConstraint")
            b.Attachment0 = a0
            b.Attachment1 = a1
            b.Parent = v.Part0

            v:Destroy()
            for e, v in pairs(c:GetChildren()) do
                if v:IsA("Part") then
                    v.CanCollide = true
                end
            end
        end
    end
    c.Head.CanCollide = true
    c.HumanoidRootPart.CanCollide = false
end

game.Players.PlayerAdded:Connect(function(p)
    p.CharacterAdded:Connect(function(ch)
        ch.Humanoid.BreakJointsOnDeath = false
        ch.Humanoid.Died:Connect(function()
            ragdoll(ch)
        end)
    end)
end)

And I am trying to convert it. Here is the currently "converted" script

local function ragdoll(c)
    for _, v in pairs(c:GetDescendants()) do
        if v:IsA("Motor6D") then
            local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
            a0.CFrame = v.C0
            a1.CFrame = v.C1
            a0.Parent = v.Part0
            a1.Parent = v.Part1

            local b = Instance.new("BallSocketConstraint")
            b.Attachment0 = a0
            b.Attachment1 = a1
            b.Parent = v.Part0

            v:Destroy()
            for e, v in pairs(c:GetChildren()) do
                if v:IsA("Part") then
                    v.CanCollide = true
                end
            end
        end
    end
    c.Head.CanCollide = true
    c.HumanoidRootPart.CanCollide = false
end

local function unragdoll(c)
    for _, v in pairs(c:GetDescendants()) do
        if v:IsA("BallSocketConstraint") or v:IsA("Attachment") then
        v:Destroy()
        end
    end
end

game.Players.PlayerAdded:Connect(function(p)
    p.CharacterAdded:Connect(function(ch)
        wait(4)
        ragdoll(ch)
        wait(4)
        unragdoll(ch)
    end)
end)

Any help on making the ragdoll not float and a unragdoll? The current unragdoll just kills the player. Taking off the Attachments/BSocketConstraints from a body part causes it to just fall off.

NOTE: I think it keeps loop-ragdolling some odd reason.

1 answer

Log in to vote
0
Answered by
zadobyte 692 Moderation Voter
4 years ago
Edited 4 years ago

For making the ragdoll not float, I'd turn on PlatformStand for the humanoid of the ragdoll. As for actually restoring the normal state, I would store the joints in some kind of folder and restore them when you see fit.

0
How would I do that? SharkTailOof 22 — 4y
0
Also I turned off platform stand but it did nothing SharkTailOof 22 — 4y
0
And platform stand is already off SharkTailOof 22 — 4y
0
You'd just make the ballsocket's parent v's Parent and put v in smth like replicated or server storage, then when you wanna, place the motor6ds back by inserting them based on the name of the attachments zadobyte 692 — 4y
View all comments (4 more)
0
Ah ok SharkTailOof 22 — 4y
0
Wait I turned on platFormStand and it helped hang on. SharkTailOof 22 — 4y
0
yeah mb, i meant on at first zadobyte 692 — 4y
0
Now the camera goes crazy (moving with the arms) and arms go through the floor AND the player still has footstep sounds and last but not least, I dont know how to I would parent all the stuff to a folder SharkTailOof 22 — 4y
Ad

Answer this question