I've been making a ragdoll death script and I've managed to get it work, mostly. There are no errors far as I know but the end result is a rather spazmatic and twisted corpse that defaults to a splits pose on the legs. I was wondering, in a ragdoll script do you need to add things like hands and feet in a R6 build to make the ragdoll come out right?
It uses constraints.
local char = script.Parent
local Torso = char.Torso
local Head = char.Head
function JointChange(part0, part1, AttachmentName, LimitsEnableYorN, UpperAngleNum)
local constraint = Instance.new("BallSocketConstraint")
constraint.Attachment0 = part0:FindFirstChild(AttachmentName)
constraint.Attachment1 = part1:FindFirstChild(AttachmentName)
if LimitsEnableYorN == true then
constraint.LimitsEnabled = true
constraint.UpperAngle = UpperAngleNum
end
constraint.Parent = char
end
char:WaitForChild("Humanoid").Died:connect(function()
script.Parent.HumanoidRootPart:Destroy()
--Limb attachments
local rightshoulderattach = Instance.new("Attachment", char:FindFirstChild("Right Arm"))
rightshoulderattach.Name = "RShoulderAttach"
rightshoulderattach.Position = Vector3.new(0, 0.5, 0)
local leftshoulderattach = Instance.new("Attachment", char:FindFirstChild("Left Arm"))
leftshoulderattach.Name = "LShoulderAttach"
leftshoulderattach.Position = Vector3.new(0, 0.5, 0)
local rightlegattach = Instance.new("Attachment", char:FindFirstChild("Right Leg"))
rightlegattach.Name = "RHipAttach"
rightlegattach.Position = Vector3.new(0, 1, 0)
local leftlegattach = Instance.new("Attachment", char:FindFirstChild("Left Leg"))
leftlegattach.Name = "LHipAttach"
leftlegattach.Position = Vector3.new(0, 1, 0)
--Torso attachments
local Trightshoulderattach = Instance.new("Attachment", Torso)
Trightshoulderattach.Name = "RShoulderAttach"
Trightshoulderattach.Position = Vector3.new(1.5, 0.5, 0)
local Tleftshoulderattach = Instance.new("Attachment", Torso)
Tleftshoulderattach.Name = "LShoulderAttach"
Tleftshoulderattach.Position = Vector3.new(-1.5, 0.5, 0)
local Trightlegattach = Instance.new("Attachment", Torso)
Trightlegattach.Name = "RHipAttach"
Trightlegattach.Position = Vector3.new(0, -1, 0)
local Tleftlegattach = Instance.new("Attachment", Torso)
Tleftlegattach.Name = "LHipAttach"
Tleftlegattach.Position = Vector3.new(0, -1, 0)
JointChange(Torso, char:FindFirstChild("Right Arm"), "RShoulderAttach", true, 90)
JointChange(Torso, char:FindFirstChild("Left Arm"), "LShoulderAttach", true, 90)
JointChange(Torso, char:FindFirstChild("Right Leg"), "RHipAttach", true, 90)
JointChange(Torso, char:FindFirstChild("Left Leg"), "LHipAttach", true, 90)
local NeckAttachment = Instance.new("Attachment", Head)
NeckAttachment.Name = "NeckAttachment"
NeckAttachment.Position = Vector3.new(0, -0.5, 0)
JointChange(Torso, Head, "NeckAttachment", true, 15)
end)
