my problem is when i use the ragdoll it works but the ragdoll dont remove and it glitches u can still walk when u ragdolled how i can fix it
here the script with problem:
function ragdoll(character)
local hum = character:FindFirstChild("Humanoid")
local rarm = character:FindFirstChild("Right Arm")
local larm = character:FindFirstChild("Left Arm")
local rleg = character:FindFirstChild("Right Leg")
local lleg = character:FindFirstChild("Left Leg")
local head = character:FindFirstChild("Head")
local torso = character:FindFirstChild("Torso")
character.Torso["Right Shoulder"]:Remove()
character.Torso["Left Shoulder"]:Remove()
character.Torso["Right Hip"]:Remove()
character.Torso["Left Hip"]:Remove()
---------
--Parts--
---------
--thing--
hum.PlatformStand = true
--right arm to torso--
local raatt1 = Instance.new("Attachment", rarm)
local raatt2 = Instance.new("Attachment", torso)
local raball = Instance.new("BallSocketConstraint", raatt2)
--left arm to torso--
local laatt1 = Instance.new("Attachment", larm)
local laatt2 = Instance.new("Attachment", torso)
local laball = Instance.new("BallSocketConstraint", laatt2)
--right leg to torso--
local rlatt1 = Instance.new("Attachment", rleg)
local rlatt2 = Instance.new("Attachment", torso)
local rlball = Instance.new("BallSocketConstraint", rlatt2)
--left leg to torso--
local llatt1 = Instance.new("Attachment", lleg)
local llatt2 = Instance.new("Attachment", torso)
local llball = Instance.new("BallSocketConstraint", llatt2)
--right arm--
raatt1.CFrame = CFrame.new(0, 1, 0)
raatt1.Name = "Right Arm Attachment1"
--left arm--
laatt1.CFrame = CFrame.new(0, 1, 0)
laatt1.Name = "Left Arm Attachment1"
--right leg--
rlatt1.CFrame = CFrame.new(0, 1, 0)
rlatt1.Name = "Right Leg Attachment1"
--left leg--
llatt1.CFrame = CFrame.new(0, 1, 0)
llatt1.Name = "Left Leg Attachment1"
--right arm--
raatt2.CFrame = CFrame.new(-1.5, 1, 0)
raatt2.Name = "Right Arm Attachment(torso)"
raball.Attachment0 = raatt2
raball.Attachment1 = raatt1
raball.Name = "Right Arm Ball"
local rapart = Instance.new("Part", rarm)
rapart.Size = Vector3.new(1, 1, 1)
rapart.Transparency = 1
rapart.CanCollide = true
rapart:BreakJoints()
local raweld = Instance.new("Weld", rapart)
raweld.Part0 = rapart
raweld.Part1 = rarm
raweld.C0 = CFrame.new(0, 0.5, 0)
--left arm--
laatt2.CFrame = CFrame.new(1.5, 1, 0)
laatt2.Name = "Left Arm Attachment(torso)"
laball.Attachment0 = laatt2
laball.Attachment1 = laatt1
laball.Name = "Left Arm Ball"
local lapart = Instance.new("Part", larm)
lapart.Size = Vector3.new(1, 1, 1)
lapart.Transparency = 1
lapart.CanCollide = true
lapart:BreakJoints()
local laweld = Instance.new("Weld", lapart)
laweld.Part0 = lapart
laweld.Part1 = larm
laweld.C0 = CFrame.new(0, 0.5, 0)
--right leg--
rlatt2.CFrame = CFrame.new(0.5, -1, 0)
rlatt2.Name = "Right Leg Attachment(torso)"
rlball.Attachment0 = rlatt2
rlball.Attachment1 = rlatt1
rlball.Name = "Right Leg Ball"
local rlpart = Instance.new("Part", rleg)
rlpart.Size = Vector3.new(1, 1, 1)
rlpart.Transparency = 1
rlpart:BreakJoints()
rlpart.CanCollide = true
local rlweld = Instance.new("Weld", rlpart)
rlweld.Part0 = rlpart
rlweld.Part1 = rleg
rlweld.C0 = CFrame.new(0, 0.5, 0)
--left leg--
llatt2.CFrame = CFrame.new(-0.5, -1, 0)
llatt2.Name = "Left Left Attachment(torso)"
llball.Attachment0 = llatt2
llball.Attachment1 = llatt1
llball.Name = "Left Leg Ball"
local llpart = Instance.new("Part", lleg)
llpart.Size = Vector3.new(1, 1, 1)
llpart.Transparency = 1
llpart.CanCollide = true
llpart:BreakJoints()
local llweld = Instance.new("Weld", llpart)
llweld.Part0 = llpart
llweld.Part1 = lleg
llweld.C0 = CFrame.new(0, 0.5, 0)
end
local function check()
while wait(0.1) do
if script.Parent.Torso.Velocity.y < -60 then
ragdoll(script.Parent)
end
end
end
spawn(check)