I’m making a Ragdoll module, everything here is working except that the parts clip through the ground.
I’ve tried to set cancollide on to the parts of the player, but it’s not working. Is someone able to help me out?
local Ragdoll = {}
function Ragdoll.Ragdoll(EnemyChar)
for _,rgd in ipairs(EnemyChar:GetDescendants()) do
if rgd:IsA("Motor6D") and rgd.Parent.Name ~= "HumanoidRootPart" then
local Ballsocket = Instance.new("BallSocketConstraint")
Ballsocket.Name = "RagdollSocket"
local Attach1 = Instance.new("Attachment")
local Attach2 = Instance.new("Attachment")
Attach1.Parent = rgd.Part0
Attach2.Parent = rgd.Part1
Ballsocket.Parent = rgd.Parent
Ballsocket.Attachment0 = Attach1
Ballsocket.Attachment1 = Attach2
Attach1.CFrame = rgd.C0
Attach2.CFrame = rgd.C1
Ballsocket.LimitsEnabled = true
Ballsocket.TwistLimitsEnabled = true
rgd.Parent.CanCollide = true
rgd:Destroy()
end
end
EnemyChar.Humanoid.RequiresNeck = false
EnemyChar.Humanoid.Sit = true
local Collide = {
[EnemyChar.LeftFoot.CanCollide] = true,
[EnemyChar.LeftHand.CanCollide] = true,
[EnemyChar.LeftLowerArm.CanCollide] = true,
[EnemyChar.LeftLowerLeg.CanCollide] = true,
[EnemyChar.LeftUpperArm.CanCollide] = true,
[EnemyChar.LeftUpperLeg.CanCollide] = true,
[EnemyChar.LowerTorso.CanCollide] = true,
[EnemyChar.RightFoot.CanCollide] = true,
[EnemyChar.RightHand.CanCollide] = true,
[EnemyChar.RightLowerArm.CanCollide] = true,
[EnemyChar.RightLowerLeg.CanCollide] = true,
[EnemyChar.RightUpperArm.CanCollide] = true,
[EnemyChar.RightUpperLeg.CanCollide] = true,
[EnemyChar.UpperTorso.CanCollide] = true,
[EnemyChar.Head.CanCollide] = true
}
end
function Ragdoll.UnRagdoll(EnemyChar)
for _,urgd in ipairs(EnemyChar:GetDescendants()) do
if urgd:IsA("BallSocketConstraint") then
urgd.UpperAngle = 0
urgd.TwistUpperAngle = 0
urgd.TwistLowerAngle = 0
local Joints = Instance.new("Motor6D", urgd.Parent)
Joints.Part0 = urgd.Attachment0.Parent
Joints.Part1 = urgd.Attachment1.Parent
Joints.C0 = urgd.Attachment0.CFrame
Joints.C1 = urgd.Attachment1.CFrame
urgd.Parent.CanCollide = false
urgd:Destroy()
end
end
EnemyChar.Humanoid.Sit = false
local UnCollide = {
[EnemyChar.LeftFoot.CanCollide] = false,
[EnemyChar.LeftHand.CanCollide] = false,
[EnemyChar.LeftLowerArm.CanCollide] = false,
[EnemyChar.LeftLowerLeg.CanCollide] = false,
[EnemyChar.LeftUpperArm.CanCollide] = false,
[EnemyChar.LeftUpperLeg.CanCollide] = false,
[EnemyChar.LowerTorso.CanCollide] = false,
[EnemyChar.RightFoot.CanCollide] = false,
[EnemyChar.RightHand.CanCollide] = false,
[EnemyChar.RightLowerArm.CanCollide] = false,
[EnemyChar.RightLowerLeg.CanCollide] = false,
[EnemyChar.RightUpperArm.CanCollide] = false,
[EnemyChar.RightUpperLeg.CanCollide] = false,
[EnemyChar.UpperTorso.CanCollide] = false,
[EnemyChar.Head.CanCollide] = false
}
end
return Ragdoll
Seems to be because EnemyChar.Humanoid.Sit = true is overwriting the state from Ragdoll to Sitting. Try removing it
EDIT: Forgot to mention that you should also disable GettingUp EnemyChar.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false) so that the ragdoll doesn’t “wake up” randomly
Oh, alright. Also how do you reset the Humanoids state back to default? For the unragdoll. And instead of disabling getting up, could I just enable platform stand?