Anyone know why this ragdoll system is causing the player to ‘dance’ and act weird?
local humanoid = script.Parent:WaitForChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(script.Parent)
print(humanoid.Name)
humanoid.BreakJointsOnDeath = false
humanoid.HealthChanged:Connect(function(h)
if h <= 25 then
for index,joint in pairs(script.Parent: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:Destroy()
local BodyForce = Instance.new("BodyForce")
BodyForce.Parent = humanoid.Parent.Torso
magnitude = 50
back = Vector3.new(0, 0, 1) * magnitude
BodyForce.Force = BodyForce.Parent.CFrame:vectorToWorldSpace(back)
end
end
end
end)