You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
a ragdoll function that works on death and when alive -
What is the issue? Include screenshots / videos if possible!
the ragdoll works perfectly when applied dead, but when alive the character just floats and slides -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
setting humanoid state to dead and ragdoll but nothing worked
local function ragdoll(npc,normal,power, backtonormal)
local r = Instance.new("StringValue", npc)
r.Name = "ragdoll"
local KnockBack = Instance.new("BodyVelocity")
KnockBack.Parent = npc:FindFirstChild("HumanoidRootPart")
KnockBack.MaxForce = Vector3.new(80000,80000,80000)
KnockBack.Velocity = Vector3.new(normal.X,0,normal.Z) * power
local Humanoid : Humanoid = npc.Humanoid
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true)
for index,joint : Motor6D in pairs(npc:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local o = Instance.new("ObjectValue")
o.Name = "joint"
o.Value = joint
o.Parent = socket
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint.Enabled = false
end
end
game:GetService("Debris"):AddItem(KnockBack, .2)
if backtonormal then
task.delay(backtonormal, function()
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
for index,socket in pairs(npc:GetDescendants()) do
if socket:IsA("BallSocketConstraint") then
socket.joint.Value.Enabled = true
socket:Destroy()
end
end
end)
end
end
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.