unlike other R15 ragdoll scripts, for some reason when I ragdoll the humanoidrootpart is attached but dangles around which is affecting the weight of my ragdoll making it very annoying!
I am using a module script and here are the two sections that is probably the issue:
Module.Joints = function(c)
local humanoid = c:FindFirstChild(“Humanoid”)
if not humanoid then return end
humanoid.BreakJointsOnDeath = false
humanoid.RequiresNeck = false
local constraintfolder = c:FindFirstChild("RagdollConstraints") or Instance.new("Folder", c)
constraintfolder.Name = "RagdollConstraints"
for _, v in pairs(c:GetDescendants()) do
if v:IsA("Motor6D") and Module.Check(v.Name) then
local attachment0 = v.Part0:FindFirstChild(v.Name.."RigAttachment") or v.Part0:FindFirstChildWhichIsA("Attachment")
local attachment1 = v.Part1:FindFirstChild(v.Name.."RigAttachment") or v.Part1:FindFirstChildWhichIsA("Attachment")
if attachment0 and attachment1 then
local ballSocket = Instance.new("BallSocketConstraint", v.Parent)
ballSocket.Attachment0 = attachment0
ballSocket.Attachment1 = attachment1
ballSocket.LimitsEnabled = true
ballSocket.TwistLimitsEnabled = true
ballSocket.Enabled = false
if not eventConnections[v.Parent] then
eventConnections[v.Parent] = v.Parent.Touched:Connect(function(hit)
if v.Parent and hit and hit:IsA("BasePart") then
local plr = game.Players:GetPlayerFromCharacter(v.Parent.Parent)
local separationThreshold = Module.GetPlayerSeparationThreshold(plr)
local force = (hit.Velocity - v.Parent.Velocity).magnitude
if force > separationThreshold then
ballSocket:Destroy()
v:Destroy()
playPlasticSound(v.Parent)
if humanoid.Health > 0 then
humanoid.Health = 0
end
end
end
end)
end
else
warn("Attachments not found for Motor6D: " .. v.Name)
end
elseif v:IsA("BasePart") then
v.CollisionGroup = "A"
if v.Name == "HumanoidRootPart" then
v.CollisionGroup = "B"
elseif v.Name == "Head" then
v.CanCollide = true
end
end
end
local collisionPairs = {
{c.LeftUpperArm, c.UpperTorso},
{c.RightUpperArm, c.UpperTorso},
{c.LeftUpperLeg, c.LowerTorso},
{c.RightUpperLeg, c.LowerTorso},
{c.LeftUpperLeg, c.UpperTorso},
{c.RightUpperLeg, c.UpperTorso},
{c.Head, c.UpperTorso},
}
for _, pair in pairs(collisionPairs) do
local noCollision = Instance.new("NoCollisionConstraint")
noCollision.Part0 = pair[1]
noCollision.Part1 = pair[2]
noCollision.Parent = constraintfolder
end
end
Module.Ragdoll = function(player, char, isRagdoll)
– Automatically fetch the player object and character
local plr = game.Players:GetPlayerFromCharacter(char)
if not plr or not char:FindFirstChild(“Humanoid”) then return end
local humanoid = char.Humanoid
local lowerTorso = char:FindFirstChild("LowerTorso")
-- Use default values for separation threshold and velocity variance if not set
local separationThreshold = Module.GetPlayerSeparationThreshold(plr)
local velocityVariance = Module.GetPlayerVelocityVariance(plr)
-- Ensure the player's character always respects ragdoll behavior
if humanoid.Health > 0 and lowerTorso and not lowerTorso.Root.Enabled and not isRagdoll then
-- Notify client to disable ragdoll effects
RE:FireClient(plr, false)
for _, v in pairs(char:GetDescendants()) do
if v:IsA("Motor6D") then
v.Enabled = true -- Re-enable motor joints for normal movement
elseif v:IsA("BallSocketConstraint") then
v.Enabled = false -- Disable physics constraints
end
end
else
-- Notify client to enable ragdoll effects
RE:FireClient(plr, true)
Module.ImpactSounds(char)
for _, v in pairs(char:GetDescendants()) do
if v:IsA("Motor6D") and Module.Check(v.Name) then
v.Enabled = false -- Disable motor joints for ragdolling
elseif v:IsA("BallSocketConstraint") then
v.Enabled = true -- Enable physics constraints
elseif v.Name == "Head" and velocityVariance > 0 then
-- Add a random velocity to the head for realistic ragdolling
local b = Instance.new("BodyVelocity", char.Head)
b.Velocity = Vector3.new(
math.random(-velocityVariance, velocityVariance),
0,
math.random(-velocityVariance, velocityVariance)
)
task.spawn(function()
wait(0.1)
b:Destroy() -- Cleanup after 0.1 seconds
end)
end
end
-- Play appropriate sounds based on health
if humanoid.Health > 0 then
playRagdollSound(char)
else
playDeathSound(char)
end
end
-- Always setup limb detachment logic to handle impacts correctly
Module.SetupLimbDetachment(plr, char, humanoid)
end
the grey part in image is the humanoidrootpart
please keep in mind my coding knowledge is VERY BAD and needed a lot of help working on this script!