I was trying to make a ragdoll death script, but instead of the characters falling back or forward, it looks like they just sit down.
And also, sometimes after falling over, the characters keep twitching.
The script just changes the Motor6D
s to BallSocketConstraint
s
-- character died event, "hit" is the part that was shot before dying
for i,v in pairs(hit.Parent:GetDescendants()) do
if v:IsA("Motor6D") then
local att0, att1 = Instance.new("Attachment"), Instance.new("Attachment");
att0.CFrame = v.C0;
att1.CFrame = v.C1;
att0.Parent = v.Part0;
att1.Parent = v.Part1;
local bleh = Instance.new("BallSocketConstraint");
bleh.Parent = v.Parent;
bleh.Attachment0 = att0;
bleh.Attachment1 = att1;
bleh.LimitsEnabled = true;
bleh.TwistLimitsEnabled = true;
bleh.MaxFrictionTorque = 20;
if string.match(v.Name, "Hip") or string.match(v.Name, "Shoulder") or string.match(v.Name, "Neck") then
bleh.TwistLowerAngle = -80;
bleh.TwistUpperAngle = 80;
else
bleh.TwistLowerAngle = -40;
bleh.TwistUpperAngle = 40;
end
if string.match(v.Name, "Hip") or string.match(v.Name, "Shoulder") or string.match(v.Name, "Waist") then
bleh.UpperAngle = 120;
else
bleh.UpperAngle = 80;
end
v:Destroy();
end
end
hit.Velocity = (gun.Shoot.Position-hit.Position).Unit * -75;
-- i also tried :ApplyImpulse but it doesn't seem to do anything
Changing any of the limits does nothing, they sit down even with LimitsEnabled
off. BreakJointsOnDeath
and RequiresNeck
are turned off in every character.
Any advice is appreciated