I’ve created a module script that allows me to create ragdolls. However, when I die, everything (except the head because I welded the head) but the arms actually go in a ragdoll state.
Here’s my module
local RagdollFunctions = {}
RagdollFunctions.Ragdoll = function(char, player)
game.ReplicatedStorage.RagdollEvent:FireClient(player, "Ragdoll")
char.Humanoid.JumpPower = 0
for _, v in pairs(char:GetDescendants()) do
if v:IsA("BasePart") and v.Name == "Head" or v.Name == "Torso" then
local weld = Instance.new("Weld")
weld.Part0 = char.HumanoidRootPart
weld.Part1 = v
weld.C0 = char.HumanoidRootPart.CFrame:inverse()
weld.C1 = v.CFrame:inverse()
weld.Parent = char.HumanoidRootPart
weld.Name = "RagdollWeld"
end
if v:IsA("Motor6D") then
local attachment1 = Instance.new("Attachment")
local attachment0 = Instance.new("Attachment")
attachment0.Name = "Attachment0"
attachment1.Name = "Attachment1"
attachment0.CFrame = v.C0
attachment1.CFrame = v.C1
attachment0.Parent = v.Part0
attachment1.Parent = v.Part1
local constraint = Instance.new("HingeConstraint")
constraint.Attachment0 = attachment0
constraint.Attachment1 = attachment1
constraint.Parent = v.Part0
v.Part0 = nil
end
end
end
function createMotor6D()
local motor6D = Instance.new("Motor6D")
return motor6D
end
RagdollFunctions.Stand = function(char, player, humanoid)
char.Humanoid.JumpPower = 50
for _, v in pairs(char:GetDescendants()) do
if v.Name == "Attachment0" or v.Name == "Attachment1" or v:IsA("Weld") and v.Name == "RagdollWeld" or v:IsA("HingeConstraint") then -- change HingeConstraint to ballsocketconstraint if thats what you chose
v:Destroy()
end
end
for _, v in pairs(char:GetDescendants()) do
if v:IsA("Motor6D") then
v.Part0 = v.Parent
end
end
game.ReplicatedStorage.RagdollEvent:FireClient(player, "Stand")
end
return RagdollFunctions