Hello! I have a ragdoll script, it works, but how to make it so that, for example, the knee does not turn out the other way as in the video:
Script:
local players = game:GetService("Players")
local constraints = {
["LeftAnkle"] = {Limits = true, Twist = true, UpperAngle = 15,LowerAngle = nil, TwistLowerAngle = -25, TwistUpperAngle = 15};
["RightAnkle"] = {Limits = true, Twist = true, UpperAngle = 15,LowerAngle = nil, TwistLowerAngle = -25, TwistUpperAngle = 15};
["LeftElbow"] = {Limits = true, Twist = false, UpperAngle = 75,LowerAngle = nil, TwistLowerAngle = nil, TwistUpperAngle = nil};
["RightElbow"] = {Limits = true, Twist = false, UpperAngle = 75,LowerAngle = nil, TwistLowerAngle = nil, TwistUpperAngle = nil};
["LeftHip"] = {Limits = true, Twist = true, UpperAngle = 35,LowerAngle = nil, TwistLowerAngle = 80, TwistUpperAngle = -25};
["RightHip"] = {Limits = true, Twist = true, UpperAngle = 35,LowerAngle = nil, TwistLowerAngle = 80, TwistUpperAngle = -25};
["LeftKnee"] = {Limits = true, Twist = false, UpperAngle = 0,LowerAngle = -100, TwistLowerAngle = nil, TwistUpperAngle = nil};--
["RightKnee"] = {Limits = true, Twist = false, UpperAngle = 0,LowerAngle = -100, TwistLowerAngle = nil, TwistUpperAngle = nil};--
["Neck"] = {Limits = true, Twist = true, UpperAngle = 5,LowerAngle = nil, TwistLowerAngle = -35, TwistUpperAngle = 40};
["LeftShoulder"] = {Limits = true, Twist = true, UpperAngle = 35,LowerAngle = nil, TwistLowerAngle = -60, TwistUpperAngle = 100};--
["RightShoulder"] = {Limits = true, Twist = true, UpperAngle = 35,LowerAngle = nil, TwistLowerAngle = -60, TwistUpperAngle = 100};--
["Waist"] = {Limits = true, Twist = true, UpperAngle = 5,LowerAngle = nil, TwistLowerAngle = -35, TwistUpperAngle = 5};
["LeftWrist"] = {Limits = true, Twist = true, UpperAngle = 15,LowerAngle = nil, TwistLowerAngle = -25, TwistUpperAngle = 25};
["RightWrist"] = {Limits = true, Twist = true, UpperAngle = 15,LowerAngle = nil, TwistLowerAngle = -25, TwistUpperAngle = 25};
} -- I tried to add restrictions, but they don't work at all
players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
if char:FindFirstChild("Humanoid") then
char:FindFirstChild("Humanoid").BreakJointsOnDeath = false
char:FindFirstChild("Humanoid").Died:Connect(function()
char.PrimaryPart.Anchored = true
local anim = script:GetChildren()
local random = math.random(1,#anim)
local animplay = char:FindFirstChild("Humanoid"):LoadAnimation(anim[random])
animplay:Play()
task.wait(math.random(0.4,1))
char.PrimaryPart.Anchored = false
for i,v in pairs(char: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 ballsocket = Instance.new("BallSocketConstraint")
ballsocket.Attachment0 = att0
ballsocket.Attachment1 = att1
ballsocket.Parent = v.Parent
local weld = Instance.new("WeldConstraint")
weld.Parent = char.Head
weld.Part0 = char.UpperTorso
weld.Part1 = char.Head
char.HumanoidRootPart.CanCollide = false
if v:IsA("BasePart") then
if v.Name ~= "HumanoidRootPart" then
v.CanCollide = true
end
end
if v.Name ~= "Root" then
ballsocket.LimitsEnabled = constraints[v.Name]["Limits"]
ballsocket.TwistLimitsEnabled = constraints[v.Name]["Twist"]
ballsocket.UpperAngle = constraints[v.Name]["UpperAngle"]
ballsocket.TwistLowerAngle = constraints[v.Name]["TwistLowerAngle"]
ballsocket.TwistUpperAngle = constraints[v.Name]["TwistUpperAngle"]
end
v:Destroy()
end
end
end)
end
end)
end)