How can I ragdoll only a limb

I have been trying to do it here’s my code (i got one from youtube and tried to modify it)

game.ReplicatedStorage.HealthEvent.LimbBreak.Event:Connect(function(v)
	local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
	a0.CFrame = v.CFrame
	a1.CFrame = v.Parent:WaitForChild("Torso").CFrame
	a0.Parent = v
	a1.Parent = v.Parent:WaitForChild("Torso")
	local b = Instance.new("BallSocketConstraint")
	b.Attachment0 = a0
	b.Attachment1 = a1
	b.Parent = v
	b.LimitsEnabled = true
	b.TwistLimitsEnabled = true
end)

Not to sure what you want but here is a code for when you press R the torso ragdolls


local player = game.Players.LocalPlayer
local userInputService = game:GetService("UserInputService")

local torso
local ragdolling = false

function findTorso(character)
    for _, part in pairs(character:GetChildren()) do
        if part:IsA("MeshPart") and part.Name == "HumanoidRootPart" then
            return part
        end
    end
end

function ragdollTorso()
    if torso then
        torso.Anchored = false
        while ragdolling and torso do
            torso.CFrame = torso.CFrame * CFrame.new(math.random(-1, 1), math.random(-1, 1), math.random(-1, 1))
            wait(0.1)
        end
    end
end

function onKeyPress(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.R then
        torso = findTorso(player.Character)
        if torso then
            ragdolling = true
            ragdollTorso()
        end
    end
end

function onKeyRelease(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.R then
        ragdolling = false
        if torso then
            torso.Anchored = true
        end
    end
end

userInputService.InputBegan:Connect(onKeyPress)
userInputService.InputEnded:Connect(onKeyRelease)

1 Like

i want it to ragdoll a limb like the arm so that only the arm go ragdoll

Like this?


local player = game.Players.LocalPlayer
local userInputService = game:GetService("UserInputService")

local rightArm
local ragdolling = false

function findRightArm(character)
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    if humanoid then
        local rig = humanoid.RigType
        if rig == Enum.HumanoidRigType.R15 then
            return character:FindFirstChild("Right Arm")
        elseif rig == Enum.HumanoidRigType.R6 then
            return character:FindFirstChild("Right Arm")
        end
    end
end

function ragdollArm()
    if rightArm then
        rightArm.Anchored = false
        while ragdolling and rightArm do
            rightArm.CFrame = rightArm.CFrame * CFrame.new(math.random(-1, 1), math.random(-1, 1), math.random(-1, 1))
            wait(0.1)
        end
    end
end

function onKeyPress(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.R then
        rightArm = findRightArm(player.Character)
        if rightArm then
            ragdolling = true
            ragdollArm()
        end
    end
end

function onKeyRelease(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.R then
        ragdolling = false
        if rightArm then
            rightArm.Anchored = true
        end
    end
end

userInputService.InputBegan:Connect(onKeyPress)
userInputService.InputEnded:Connect(onKeyRelease)

1 Like

for some reason it’s not working (it’s making the baseplate tremble)

and it’s not only the arm, i need to detect what limb it will ragdoll when that event fires

Ok I’m not very good at coding and this is just modified stuff from games I’ve made

1 Like

oh alright then, I just need to make only a limb go ragdoll, but thanks for the help!

1 Like