function Ragdoll(guy, ragdolltime)
if CS:HasTag(guy, “Ragdoll”) == true then
return
end
task.spawn(function()
local hum = guy.Humanoid
local hh = hum.HipHeight
CS:AddTag(guy, “Ragdoll”)
guy:AddTag(“Stun”)
hum.HipHeight = 0
hum.AutoRotate = false
hum.PlatformStand = true
– guy.Humanoid.Sit = true
guy.Humanoid.JumpPower = 0
guy.Humanoid.JumpHeight = 0
for index, joint in pairs(guy:GetDescendants()) do
if joint:IsA(“Motor6D”) then
local socket = Instance.new(“BallSocketConstraint”)
local a1 = Instance.new(“Attachment”)
local a2 = Instance.new(“Attachment”)
a1.Name = “ata1”
a2.Name = “ata2”
socket.Name = “soket”
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
endtask.wait(ragdolltime) hum:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false) hum:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false) CS:RemoveTag(guy, "Ragdoll") guy:Remove("Stun") -- guy.Humanoid.Sit = false guy.HumanoidRootPart.Orientation = Vector3.new(0,guy.HumanoidRootPart.Orientation.Y,0) hum.PlatformStand = false hum.HipHeight = hh hum.AutoRotate = true guy.Humanoid.JumpPower = 50 guy.Humanoid.JumpHeight = 7.2 for index, joint in pairs(guy:GetDescendants()) do if joint:IsA("Motor6D") then joint.Enabled = true elseif joint.Name == "ata1" or joint.Name == "ata2" or joint.Name == "soket" then joint:Destroy() end end
end)
end
so here i have a ragdoll script but when i use it on an enemy, the enemy gets destroyed instantly