Quick actions

cmd+k|ctrl+k

Navigation

Languages

hl2ded

Snippet info

Language

Lua

Visibility

public

Author

zen

Created

2024-01-01T13:54:08.314128Z

Updated

2024-01-01T13:54:08.314128Z

local character = owner.Character or owner.CharacterAdded:Wait()

local humanoid: Humanoid = character:WaitForChild("Humanoid")
local torso: Part = character:WaitForChild("Torso")

humanoid.BreakJointsOnDeath = false

local function ragdoll()
	for _,joint in pairs(character:GetDescendants()) do
		if not joint:IsA("Motor6D") then continue end
		
		local socket = Instance.new("BallSocketConstraint")
		local attachment0 = Instance.new("Attachment")
		local attachment1 = Instance.new("Attachment")
		
		attachment0.Parent = joint.Part0
		attachment1.Parent = joint.Part1
		
		socket.Parent = joint.Parent
		socket.Attachment0 = attachment0
		socket.Attachment1 = attachment1
		
		attachment0.CFrame = joint.C0
		attachment1.CFrame = joint.C1
		
		socket.TwistLimitsEnabled = true
		socket.LimitsEnabled = true
		
		joint:Destroy()
	end
	torso:ApplyAngularImpulse(Vector3.new(25,25,25) * torso:GetMass())
end

humanoid.Died:Connect(function()
	ragdoll()
	local sound = Instance.new("Sound")
	sound.SoundId = "rbxassetid://9060084190"
	sound.Volume = 1
	sound.Parent = torso
	sound:Play()
end)
INFO