This script works for the most part. when the player gets the ragdoll effect, they go limp or when they die they also flop over. But a weird edge case is when the player JUMPs right before the ragdoll right before the peak of the jump, or I think that is what happens, causes them to still get ragdolled but float in the air continuously and I don’t know why.
local Players = game:GetService("Players")
local offsets = {
Head = {
CFrame = {CFrame.new(0, 1, 0, 0, -1, 0, 1, 0, -0, 0, 0, 1), CFrame.new(0, -0.5, 0, 0, -1, 0, 1, 0, -0, 0, 0, 1)}
},
HumanoidRootPart = {
CFrame = {CFrame.new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), CFrame.new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)}
},
["Right Arm"] = {
CFrame = {CFrame.new(1.3, 0.75, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), CFrame.new(-0.2, 0.75, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)}
},
["Left Arm"] = {
CFrame = {CFrame.new(-1.3, 0.75, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1), CFrame.new(0.2, 0.75, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1)}
},
["Right Leg"] = {
CFrame = {CFrame.new(0.5, -1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1), CFrame.new(0, 1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1)}
},
["Left Leg"] = {
CFrame = {CFrame.new(-0.5, -1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1), CFrame.new(0, 1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1)}
}
}
local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
local function SetUpColliders(character: Model)
for _, v in pairs(character:GetChildren()) do
if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
if not v:FindFirstChild("Collide") then
local c = v:Clone()
c.Parent = v
c.Massless = true
c.Size = Vector3.one
c.Name = "Collide"
c.Transparency = 1
c:ClearAllChildren()
local weld = Instance.new("Weld")
weld.Parent = c
weld.Part0 = v
weld.Part1 = c
end
end
end
end
local function EnableCollision(character: Model, bool: boolean)
for _, v in pairs(character:GetDescendants()) do
if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" and v.Name ~= "Collide" then
local col = v:FindFirstChild("Collide")
if col then
col.CanCollide = bool
end
v.CanCollide = not bool
end
end
end
local function EnableMotor6D(character: Model, bool: boolean)
for _, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") then
if v.Name == "Handle" or v.Name == "RootJoint" or v.Name == "Neck" then continue end
if v:FindFirstAncestorOfClass("Accessory") then continue end
v.Enabled = bool
end
end
end
local function BuildJoints(character: Model)
local hrp = character:WaitForChild("HumanoidRootPart")
for _, v in pairs(character:GetDescendants()) do
if not v:IsA("BasePart")
or v:FindFirstAncestorOfClass("Accessory")
or v.Name == "Handle"
or v.Name == "Torso"
or v.Name == "HumanoidRootPart"
then
continue
end
if not offsets[v.Name] then continue end
if v:FindFirstChild("RagdollAttachment") then continue end -- prevent duplicates
local a0: Attachment, a1: Attachment = Instance.new("Attachment"), Instance.new("Attachment")
local joint: Constraint = Instance.new("BallSocketConstraint")
a0.Name = "RagdollAttachment"
a0.Parent = v
a0.CFrame = offsets[v.Name].CFrame[2]
a1.Name = "RagdollAttachment"
a1.Parent = hrp
a1.CFrame = offsets[v.Name].CFrame[1]
joint.Name = "RagdollJoint"
joint.Parent = v
joint.Attachment0 = a0
joint.Attachment1 = a1
v.Massless = true
end
end
local function breakJoints(character: Model)
for _, v in pairs(character:GetDescendants()) do
if v.Name == "RagdollAttachment" then v:Destroy() end
if v.Name == "RagdollJoint" then v:Destroy() end
end
end
local function monitorPlayer(character: Model)
local existing = character:FindFirstChild("Ragdoll")
if existing then
EnableMotor6D(character, false)
EnableCollision(character, true)
BuildJoints(character)
end
character.ChildAdded:Connect(function(child)
if child.Name == "Ragdoll" then
EnableMotor6D(character, false)
EnableCollision(character, true)
BuildJoints(character)
local Humanoid: Humanoid = character:WaitForChild("Humanoid")
Humanoid.AutoRotate = false
Humanoid.PlatformStand = true
Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true)
local humanoidRootPart: BasePart = character:WaitForChild("HumanoidRootPart")
if humanoidRootPart.Parent then
humanoidRootPart:SetNetworkOwner(nil)
end
end
end)
character.ChildRemoved:Connect(function(child)
if child.Name == "Ragdoll" then
breakJoints(character)
EnableMotor6D(character, true)
EnableCollision(character, false)
local Humanoid: Humanoid = character:WaitForChild("Humanoid")
Humanoid.AutoRotate = true
Humanoid.PlatformStand = false
Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
local humanoidRootPart: BasePart = character:WaitForChild("HumanoidRootPart")
if humanoidRootPart.Parent then
humanoidRootPart:SetNetworkOwnershipAuto()
end
end
end)
end
local function onCharacterAdded(character)
task.wait(0.02)
SetUpColliders(character)
monitorPlayer(character)
local humanoid = character:FindFirstChildOfClass("Humanoid")
humanoid.BreakJointsOnDeath = false
humanoid.RequiresNeck = false
if humanoid then
humanoid.Died:Connect(function()
local dontRag = character:GetAttribute("DontRagdoll")
if not character:FindFirstChild("Ragdoll") and not dontRag then
local ragdollTag = Instance.new("BoolValue")
ragdollTag.Name = "Ragdoll"
ragdollTag.Parent = character
end
end)
end
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end
end
for _, player in Players:GetPlayers() do
onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)