For as long as this ragdoll script of mine had been created, I’ve always had a flinging problem. Randomly, whenever you bumped into another character in my games including ragdoll, you would always be flung. I know this only occurs because of the ragdoll because when it was disabled, no fling occured.
I have no idea why this is happening. Maybe it is outdated now, or I’m doing something wrong?
Maybe it’s what I do in the script itself.
local function Glue(par, c0, c1, part0, part1, nam)
local glue = Instance.new("Glue")
glue.Name = nam
glue.C0 = c0
glue.C1 = c1
glue.Part0 = part0
glue.Part1 = part1
glue.Parent = par
end
local function Joint(par, c0, c1, part0, part1, nam)
local motor = Instance.new("Motor6D")
motor.Name = nam
motor.C0 = c0
motor.C1 = c1
motor.Part0 = part0
motor.Part1 = part1
motor.Parent = par
end
local function Touch(par, limb, cframe)
local pr = Instance.new("Part")
pr.Name = "touchy"
pr.Size = Vector3.new(1, 1, 1)
pr.Transparency = 1
pr.CustomPhysicalProperties = PhysicalProperties.new(.55, .3, .5)
pr.CanCollide = true
pr.Anchored = false
pr.Parent = par
local w = Instance.new("Weld")
w.Part0 = pr
w.Part1 = limb
w.C0 = cframe
w.Parent = pr
end
local humanoid = character:WaitForChild("Humanoid")
local rag = character:FindFirstChild("Ragdoll", true)
local root = character:WaitForChild("HumanoidRootPart")
local rightArm = character["Right Arm"]
local leftArm = character["Left Arm"]
local rightLeg = character["Right Leg"]
local leftLeg = character["Left Leg"]
local rsC0 = CFrame.new(1.5 * 1, 0.5 * 1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
local rsC1 = CFrame.new(0, 0.5 * 1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
local lsC0 = CFrame.new(-1.5 * 1, 0.5 * 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
local lsC1 = CFrame.new(0, 0.5 * 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
local rhC0 = CFrame.new(0.5 * 1, -1 * 1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
local rhC1 = CFrame.new(0, 1 * 1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
local lhC0 = CFrame.new(-0.5 * 1, -1 * 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
local lhC1 = CFrame.new(0 * 1, 1 * 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
character.Blocking.Value = false
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true)
root.CanCollide = false
root.Massless = true
humanoid.PlatformStand = true
if (root:FindFirstChild("OOF") and not root:FindFirstChild("OOF").IsPlaying) and humanoid.Health <= 1 then
root.OOF:Play()
root.OOF.TimePosition = .5
end
humanoid.AutoRotate = false
if rightArm and torso:FindFirstChild("Right Shoulder") then
torso:FindFirstChild("Right Shoulder"):Destroy()
Glue(torso, rsC0, rsC1, torso, rightArm, "Right Shoulder")
Touch(rightArm, rightArm, CFrame.new(0, .5, 0))
end
if leftArm and torso:FindFirstChild("Left Shoulder") then
torso:FindFirstChild("Left Shoulder"):Destroy()
Glue(torso, lsC0, lsC1, torso, leftArm, "Left Shoulder")
Touch(leftArm, leftArm, CFrame.new(0, .5, 0))
end
if rightLeg and torso:FindFirstChild("Right Hip") then
torso:FindFirstChild("Right Hip"):Destroy()
Glue(torso, rhC0, rhC1, torso, rightLeg, "Right Hip")
Touch(rightLeg, rightLeg, CFrame.new(0, .5, 0))
end
if leftLeg and torso:FindFirstChild("Left Hip") then
torso:FindFirstChild("Left Hip"):Destroy()
Glue(torso, lhC0, lhC1, torso, leftLeg, "Left Hip")
Touch(leftLeg, leftLeg, CFrame.new(0, .5, 0))
end
-- After ragdoll is done
Joint(torso, rsC0, rsC1, torso, rightArm, "Right Shoulder")
if rightArm:FindFirstChild("touchy") then
rightArm:FindFirstChild("touchy"):Destroy()
end
end
if leftArm and torso:FindFirstChild("Left Shoulder") then
torso:FindFirstChild("Left Shoulder"):Destroy()
Joint(torso, lsC0, lsC1, torso, leftArm, "Left Shoulder")
if leftArm:FindFirstChild("touchy") then
leftArm:FindFirstChild("touchy"):Destroy()
end
end
if rightLeg and torso:FindFirstChild("Right Hip") then
torso:FindFirstChild("Right Hip"):Destroy()
Joint(torso, rhC0, rhC1, torso, rightLeg, "Right Hip")
if rightLeg:FindFirstChild("touchy") then
rightLeg:FindFirstChild("touchy"):Destroy()
end
end
if leftLeg and torso:FindFirstChild("Left Hip") then
torso:FindFirstChild("Left Hip"):Destroy()
Joint(torso, lhC0, lhC1, torso, leftLeg, "Left Hip")
if leftLeg:FindFirstChild("touchy") then
leftLeg:FindFirstChild("touchy"):Destroy()
end
end
humanoid.PlatformStand = false
humanoid.AutoRotate = true
root.Massless = false
humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
spawn(function()
for i = 1, 20 do
root.Velocity = Vector3.new(0, 0, 0)
wait(.05)
end
end)
local bg = Instance.new("BodyGyro")
bg.P = 1000000
bg.D = 500
bg.MaxTorque = Vector3.new(math.huge, 0, math.huge)
bg.Parent = root
game.Debris:AddItem(bg, .1)
root.CanCollide = true
Please, tell me what I’m doing wrong. This is a crucial point of my game, as ragdoll is used almost everytime an action is performed.