Hey this is my ragdoll + damage script and the problem is that i want the player to never die so i did that by setting the health to 1 each time it was about to die. But when i did the ragdoll and when the ragdoll goes back after reaching 50 health it doesn’t work properly
here is my full damage + ragdoll script:
game.ReplicatedStorage.DamageEvents.Damage.Event:Connect(function(Char, Damage)
print("Damage is happening")
if Damage < Char.Humanoid.Health then
Char.Humanoid.Health -= Damage
print("Damaged"..Damage.."HP")
else
Char.Humanoid.Health = 1
if game.Players:GetPlayerFromCharacter(Char) ~= nil then
print("Player = True")
local Player = game.Players:GetPlayerFromCharacter(Char)
local Tools = Player.Backpack:GetChildren()
for _, v in pairs(Tools) do
v:Destroy()
end
local hum = Char:WaitForChild("Humanoid")
hum.BreakJointsOnDeath = false
local joints = Char:GetDescendants()
for _,joint in pairs(joints) do
if joint:isA("Motor6D") then
local socket = Instance.new("BallSocketConstraint", joint.Parent)
local a0 = Instance.new("Attachment")
a0.Name = "Attachment1"
local a1 = Instance.new("Attachment")
socket.Attachment0 = a0
socket.Attachment1 = a1
a0.Parent = joint.Part0
a1.Parent = joint.Part1
a0.CFrame = joint.C0
a1.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint:Destroy()
end
end
Char.Humanoid.HealthChanged:Connect(function(Health)
if Health >= 50 then
for i,v in pairs(Char:GetDescendants()) do
if v.Name == "BallSocketConstraint" then
v:Destroy()
elseif v.Name == "Attachment1" then
v:Destroy()
elseif v.Name == "Attachment" then
v:Destroy()
end
end
return Health
end
end)
end
end
end)
Here is the script i use to try to stop the ragdoll:
Char.Humanoid.HealthChanged:Connect(function(Health)
if Health >= 50 then
for i,v in pairs(Char:GetDescendants()) do
if v.Name == "BallSocketConstraint" then
v:Destroy()
elseif v.Name == "Attachment1" then
v:Destroy()
elseif v.Name == "Attachment" then
v:Destroy()
end
end
return Health
end
end)
If u know the answer please respond.
I want to achieve a dahood ish ragdoll system