I'm experiencing an odd issue with a custom ragdoll script. I did not make this from scratch, however I believed I had a good understanding on how it worked.
This code does work well. The problem is it doesn't work with uploaded meshes that are used as an Accessory. I have custom hair that I uploaded within the past month. These have been positioned properly, Attachments made, and placed properly in the Accessory and placed properly on the character. The issue is when the player dies and the ragdoll code fires, the character is deleted.
Here is where it gets confusing...if I use an uploaded mesh from 3 years ago, the character ragdolls properly without deleting the character. It seems to only delete the character when the Accessory is using a mesh that I uploaded in the past month. ROBLOX accessories seem to work fine with the ragdoll code as well. Has something changed with how the newer meshes are uploaded that could be causing an issue? The settings between the 3 year old mesh and the mesh created this month are identical.
Thanks for your input!
local character = script.Parent
local player = game.Players:FindFirstChild(script.Parent.Name)
character:WaitForChild("Humanoid").Died:Connect(function()
script.Parent.CharStatus.Downed.Value = true
local function ragdollJoint(part0,part1,attachmentName,className,properties)
attachmentName = attachmentName.."RigAttachment"
local constraint = Instance.new(className.."Constraint")
constraint.Attachment0 = part0:FindFirstChild(attachmentName)
constraint.Attachment1 = part1:FindFirstChild(attachmentName)
constraint.Name = "RagdollConstraint"..part1.Name
for _,propertyData in next,properties or {} do
constraint[propertyData[1]] = propertyData[2]
end
constraint.Parent = character
end
local function getAttachment0(attachmentName)
for _,child in next,character:GetChildren() do
local attachment = child:FindFirstChild(attachmentName)
if attachment then
return attachment
end
end
end
for _,child in next,character:GetChildren() do
if child:IsA("Accoutrement") then
for _,part in next,child:GetChildren() do
if part:IsA("BasePart") then
local attachment1 = part:FindFirstChildOfClass("Attachment")
local attachment0 = getAttachment0(attachment1.Name)
if attachment0 and attachment1 then
local constraint = Instance.new("HingeConstraint")
constraint.Attachment0 = attachment0
constraint.Attachment1 = attachment1
constraint.LimitsEnabled = true
constraint.UpperAngle = 0
constraint.LowerAngle = 0
constraint.Parent = character
end
end
end
end
end
ragdollJoint(character.LowerTorso, character.UpperTorso, "Waist", "BallSocket", {
{"LimitsEnabled",true};
{"UpperAngle",5};
})
ragdollJoint(character.UpperTorso, character.Head, "Neck", "BallSocket", {
{"LimitsEnabled",true};
{"UpperAngle",15};
})
local handProperties = {
{"LimitsEnabled", true};
{"UpperAngle",0};
{"LowerAngle",0};
}
ragdollJoint(character.LeftLowerArm, character.LeftHand, "LeftWrist", "Hinge", handProperties)
ragdollJoint(character.RightLowerArm, character.RightHand, "RightWrist", "Hinge", handProperties)
local shinProperties = {
{"LimitsEnabled", true};
{"UpperAngle", 0};
{"LowerAngle", -75};
}
ragdollJoint(character.LeftUpperLeg, character.LeftLowerLeg, "LeftKnee", "Hinge", shinProperties)
ragdollJoint(character.RightUpperLeg, character.RightLowerLeg, "RightKnee", "Hinge", shinProperties)
local footProperties = {
{"LimitsEnabled", true};
{"UpperAngle", 15};
{"LowerAngle", -45};
}
ragdollJoint(character.LeftLowerLeg, character.LeftFoot, "LeftAnkle", "Hinge", footProperties)
ragdollJoint(character.RightLowerLeg, character.RightFoot, "RightAnkle", "Hinge", footProperties)
ragdollJoint(character.UpperTorso, character.LeftUpperArm, "LeftShoulder", "BallSocket")
ragdollJoint(character.LeftUpperArm, character.LeftLowerArm, "LeftElbow", "BallSocket")
ragdollJoint(character.UpperTorso, character.RightUpperArm, "RightShoulder", "BallSocket")
ragdollJoint(character.RightUpperArm, character.RightLowerArm, "RightElbow", "BallSocket")
ragdollJoint(character.LowerTorso, character.LeftUpperLeg, "LeftHip", "BallSocket")
ragdollJoint(character.LowerTorso, character.RightUpperLeg, "RightHip", "BallSocket")
wait(5)
if character:FindFirstChild("UpperTorso") then
print("DROP WORKED PROPERLY")
local Position = character.UpperTorso.CFrame
player:LoadCharacter()
player.Character.HumanoidRootPart.CFrame = Position
player.Character.Humanoid.Health = 10
else
print("DROP WAS GLITHCED....SORRY!! RESPAWN TO VILLAGE")
player:LoadCharacter()
end
end)

1 comment
The code is properly indented. The new input to ask a question is not very user friendly. I could not get the code to paste and source properly.