When my roblox character turns ragdoll, and i try to reset it will refuse to die, (ONLY WHEN USING THE RESET BUTTON), its a really weird bug, when setting the humanoid’s health to 0 it will actually die, and when using the reset button whitout being ragdoll it the player will die too
here is a demostration of the player resetting (Whitout being ragdoll)
here is a demostration of the player resetting being ragdoll
here is the module script i made (there is other scripts too that are important for ragdoll but im not showing them because im lazy)
local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local RagdollValue_Changed = game.ReplicatedStorage.RemoteEvents.RagdollValue_Changed_RemoteEvent
--> Specific CFrame's no_loop made for the best looking Ragdoll
local attachmentCFrames = {
["Neck"] = {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)},
["Left Shoulder"] = {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 Shoulder"] = {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 Hip"] = {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)},
["Right Hip"] = {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)},
}
-------------------------------------------------------------------------------------------------
RagdollModule = {}
function RagdollModule.Push(Offender: Model, VictimPart: Part, force: number)
local Attachment = Instance.new("Attachment", VictimPart)
Attachment.Name = "Attachment"
local VectorForce = Instance.new("VectorForce", VictimPart)
VectorForce.Name = "Force"
VectorForce.RelativeTo = Enum.ActuatorRelativeTo.World
VectorForce.Attachment0 = Attachment
local Direction
if Offender then
Direction = (VictimPart.Position - Offender.HumanoidRootPart.Position).Unit
else
Direction = VictimPart.CFrame.LookVector
end
Direction = Vector3.new(Direction.X, 0 , Direction.Z)
Direction = Direction * force + Vector3.new(math.random(100,200), math.random(50,100), math.random(100,200))
VectorForce.Force = Direction
Debris:AddItem(Attachment, 0.35)
Debris:AddItem(VectorForce, 0.35)
print("pushed the player")
end
--> Allows for proper limb collisions
function RagdollModule.createCollisionParts(Character : Model)
for _, Part in Character:GetChildren() do
if Part:IsA("BasePart") and Part.Name ~= "HumanoidRootPart" then
local Clone = Part:Clone()
Clone.Name = "Collider"
Clone.Massless = true
Clone.Size = Part.Size/1.7
Clone.Transparency = 1
Clone.CanCollide = false
Clone.Parent = Part
Clone.CollisionGroup = "CharacterCollisionGroup"
Clone:ClearAllChildren()
local Weld = Instance.new("Weld")
Weld.Parent = Clone
Weld.Part1 = Clone
Weld.Part0 = Part
end
end
end
function EnableCollsionParts(Character: Model, Value)
for _, Part in Character:GetChildren() do
if Part:IsA("BasePart") and Part.Name ~= "HumanoidRootPart" then
local Collider: BasePart = Part.Collider
Part.CanCollide = not Value --> Inverts the value, if true sets parts to false and sets Colliders to true, etc
Collider.CanCollide = Value
end
end
end
--> Creates BallSocketConstraints
function CreateJoints(Character: Model)
local hrp = Character.HumanoidRootPart
for _, Motor in Character:GetDescendants() do
if Motor:IsA("Motor6D") then
if not attachmentCFrames[Motor.Name] then return end
local a0: Attachment , a1: Attachment = Instance.new("Attachment"), Instance.new("Attachment")
local b: BallSocketConstraint = Instance.new("BallSocketConstraint")
a0.CFrame = attachmentCFrames[Motor.Name][1]
a1.CFrame = attachmentCFrames[Motor.Name][2]
a0.Name = "RAGDOLL_ATTACHMENT"
a0.Parent = hrp
a1.Name = "RAGDOLL_ATTACHMENT"
a1.Parent = Motor.Part1
b.Parent = Motor.Parent
b.Name = "RAGDOLL_CONSTRAINT"
b.Attachment0 = a0
b.Attachment1 = a1
b.Radius = 0.15
b.LimitsEnabled = true
b.TwistLimitsEnabled = false
b.MaxFrictionTorque = 0
b.Restitution = 0
b.UpperAngle = 90
b.TwistLowerAngle = -45
b.TwistUpperAngle = 45
if Motor.Name == "Neck" then
b.TwistLimitsEnabled = true
b.UpperAngle = 45
b.TwistLowerAngle = -70
b.TwistUpperAngle = 70
end
end
end
end
function DestroyJoints(Character: Model)
for _, child in Character:GetDescendants() do
if child.Name == "RAGDOLL_ATTACHMENT" then child:Destroy() print("destroyed") end
if child.Name == "RAGDOLL_CONSTRAINT" then child:Destroy() print("destroyed") end
end
end
function EnableMotor6D(Character: Model, Value: BoolValue)
for _, child in Character:GetDescendants() do
if child.Name == "Handle" or child.Name == "RootJoint" or child.Name == "Neck" then continue end
if child:IsA("Motor6D") then child.Enabled = Value end
end
end
function RagdollModule.Ragdoll(value: boolean, Humanoid: Humanoid, time: number)
local Character: Model = Humanoid.Parent
local hrp: BasePart = Character.HumanoidRootPart
local Player: Player = Players:GetPlayerFromCharacter(Character)
if value then
if Player then
RagdollValue_Changed:FireClient(Player, value)
print("Fire to client")
end
hrp:SetNetworkOwner(nil)
Humanoid.AutoRotate = false
Humanoid.PlatformStand = true
CreateJoints(Character)
EnableMotor6D(Character, false)
EnableCollsionParts(Character, true)
else
if Player then
RagdollValue_Changed:FireClient(Player, value)
end
hrp:SetNetworkOwner(nil)
Humanoid.AutoRotate = true
Humanoid.PlatformStand = false
EnableMotor6D(Character, true)
DestroyJoints(Character)
EnableCollsionParts(Character, false)
end
end
return RagdollModule
in the other script im also doing this (not the full script)
Torso.CollisionGroup = "CharacterCollisionGroup"
Character.Head.CollisionGroup = "CharacterCollisionGroup"
--> Necessary for Ragdolling to function properly
Character.Humanoid.BreakJointsOnDeath = false
Character.Humanoid.RequiresNeck = false
--> Used to trigger Ragdoll
local RagdollValue = Instance.new("BoolValue")
RagdollValue.Name = "RagdollValue"
RagdollValue.Parent = Character
--> creates ragdoll collision parts
ModuleLoader:GetServices("RagdollHumanoidModule").createCollisionParts(Character)
--> Toggles Ragdoll depending on RagdollValue
RagdollValue.Changed:Connect(function(Boolean)
ModuleLoader:GetServices("RagdollHumanoidModule").Ragdoll(Boolean, Character.Humanoid)
end)
Humanoid.Died:Connect(function()
if hrp then
RagdollValue.Value = true
--ModuleLoader:GetServices("RagdollHumanoidModule").Push(nil, Character.Head, 500)
end
end)