I’ve been working to make a ragdoll script in my game. But when the ragdoll triggers, the limbs clip through the baseplate. Ive tried setting CanCollide on for the limbs and using no collision constraints but neither have worked for me
This is my code:
enemyhum:ChangeState(Enum.HumanoidStateType.Ragdoll)
for i, v in pairs(hit.Parent:GetDescendants()) do
if v:IsA("Motor6D") and v.Enabled == true then
enemyhum.RequiresNeck = false
local socket = Instance.new("BallSocketConstraint")
local a0 = Instance.new("Attachment")
local a1 = Instance.new("Attachment")
socket.Parent = v.Parent
a0.Parent = v.Part0
a1.Parent = v.Part1
socket.Attachment0 = a0
socket.Attachment1 = a1
a0.CFrame = v.C0
a1.CFrame = v.C1
socket.TwistLimitsEnabled = true
socket.LimitsEnabled = true
v.Enabled = false
end
if v:IsA("MeshPart") or v:IsA("Part") then
print(v)
v.Anchored = false; v.CanCollide = true
end
end
local hum = hit.Parent:FindFirstChild("Humanoid")
hum.AutoRotate = false
hum.PlatformStand = true
Hey there! You can use my ragdoll script, it works completely fine!
for i, joint in pairs(character:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint.Enabled = false
end
end
end
Also, turn off BreakJointsOnDeath for the humanoid, or do it in the script.
doing these things makes the situation a tad bit better but the limbs still collide through the floor when using your script and turning off breakjointsondeath
You can make a clone of a body part, clear everything inside of it, parent it to the original body part, weld the clone and the original body part and then put the clone into a table, you can do this with a for loop above the for loop that creates the ball socket
and then after making the clone body parts set the collision to false, so later, when your character ragdolls, you can set the cloned body part CanCollide to true, and vice versa
You should try humanoid state type of Physics instead of the deprecated Ragdoll state. It gives you control over what can be made collidable without the engine immediately undoing your changes.