i have a ragdoll script that destroys the player and creates a ragdoll of them when they die, however just recently the ragdoll script doe seem to properly turn the player into a ragdoll, and the arms and legs are supposed to flop around however the players just stays in a motionless state, is there any way to fix this?
CORPSE_LIFETIME = 5
function HandleCharacterDeath(Player, Character, Humanoid)
Humanoid.Died:connect(function()
Character.Archivable = true
local Corpse = Character:Clone()
Corpse.Name = Player.Name.." Corpse"
if Corpse:FindFirstChild("Humanoid") then
local Humanoid = Corpse.Humanoid
Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
Humanoid.Health = 0
Humanoid.MaxHealth = 0
Humanoid.PlatformStand = true
end
for _,Child in pairs(Corpse:GetChildren()) do
if Child:IsA("Script") or Child:IsA("LocalScript") or Child:IsA("Hat") then
Child:Destroy()
elseif Child:IsA("BasePart") and (Child.Name == "TorsoArm" or Child.Name == "ToolArm" or Child.Name == "HumanoidRootPart") then
Child:Destroy()
elseif Child:IsA("BasePart") then
Child.CanCollide = true
for _,Grandchild in pairs(Child:GetChildren()) do
if Grandchild:IsA("JointInstance") then
Grandchild:Destroy()
end
end
elseif Child:IsA("Model") then
Child:Destroy()
end
end
Corpse.Parent = workspace
local incase = script.Script:Clone()
incase.Parent = Corpse
incase.Disabled = false
wait(0.01)
Player.Character.Parent = nil
if Corpse:FindFirstChild("Head") then
local DeathSoundIDs = {165260224,138080273,705821735}
local DeathSound = Instance.new("Sound",Corpse.Head)
DeathSound.Volume = 1
DeathSound.SoundId = "rbxassetid://"..DeathSoundIDs[math.random(1,#DeathSoundIDs)]
DeathSound:Play()
end
TurnCharacterIntoRagdoll(Corpse, Player)
game:GetService("Debris"):AddItem(Corpse, CORPSE_LIFETIME)
end)
end
function TurnCharacterIntoRagdoll(Character, Player)
local PlayerName = Player.Name
local Torso = Character.Torso
local Head = Character["Head"]
local HeadGlue = Instance.new("Glue", Head)
HeadGlue.Part0, HeadGlue.Part1 = Torso, Head
HeadGlue.C0 = CFrame.new(0,1,0)
HeadGlue.C1 = CFrame.new(0,-0.5,0)
HeadGlue.F0 = Vector3.new(0.05,0,0.05)
HeadGlue.F1 = Vector3.new(-0.05,0,0.05)
HeadGlue.F2 = Vector3.new(0.05,0,-0.05)
HeadGlue.F3 = Vector3.new(-0.05,0,-0.05)
local LArm = Character["Left Arm"]
local LArmGlue = Instance.new("Glue", LArm)
LArmGlue.Part0, LArmGlue.Part1 = Torso, LArm
LArmGlue.C0 = CFrame.new(-1.5,1,0)
LArmGlue.C1 = CFrame.new(0,1,0)
local LArmCollision = Instance.new("Part",Character)
LArmCollision.TopSurface, LArmCollision.BottomSurface = Enum.SurfaceType.Smooth, Enum.SurfaceType.Smooth
LArmCollision.formFactor = Enum.FormFactor.Custom
LArmCollision.Size, LArmCollision.Transparency = Vector3.new(0.9,0.9,0.9), 1
local LArmWeld = Instance.new("Weld",LArmCollision)
LArmWeld.Part0, LArmWeld.Part1 = LArm, LArmCollision
local RArm = Character["Right Arm"]
local RArmGlue = Instance.new("Glue", RArm)
RArmGlue.Part0, RArmGlue.Part1 = Torso, RArm
RArmGlue.C0 = CFrame.new(1.5,1,0)
RArmGlue.C1 = CFrame.new(0,1,0)
local RArmCollision = Instance.new("Part",Character)
RArmCollision.TopSurface, RArmCollision.BottomSurface = Enum.SurfaceType.Smooth, Enum.SurfaceType.Smooth
RArmCollision.formFactor = Enum.FormFactor.Custom
RArmCollision.Size, RArmCollision.Transparency = Vector3.new(0.9,0.9,0.9), 1
local RArmWeld = Instance.new("Weld",RArmCollision)
RArmWeld.Part0, RArmWeld.Part1 = RArm, RArmCollision
local LLeg = Character["Left Leg"]
local LLegGlue = Instance.new("Glue", LLeg)
LLegGlue.Part0, LLegGlue.Part1 = Torso, LLeg
LLegGlue.C0 = CFrame.new(-0.5,-1,0)
LLegGlue.C1 = CFrame.new(0,1,0)
LLegGlue.F0 = Vector3.new(0.01,0.01,0)
LLegGlue.F1 = Vector3.new(-0.01,0.01,0)
LLegGlue.F2 = Vector3.new(0.01,-0.01,0)
LLegGlue.F3 = Vector3.new(-0.01,-0.01,0)
local LLegCollision = Instance.new("Part",Character)
LLegCollision.TopSurface, LLegCollision.BottomSurface = Enum.SurfaceType.Smooth, Enum.SurfaceType.Smooth
LLegCollision.formFactor = Enum.FormFactor.Custom
LLegCollision.Size, LLegCollision.Transparency = Vector3.new(0.9,0.9,0.9), 1
local LLegWeld = Instance.new("Weld",LLegCollision)
LLegWeld.Part0, LLegWeld.Part1 = LLeg, LLegCollision
local RLeg = Character["Right Leg"]
local RLegGlue = Instance.new("Glue", RLeg)
RLegGlue.Part0, RLegGlue.Part1 = Torso, RLeg
RLegGlue.C0 = CFrame.new(0.5,-1,0)
RLegGlue.C1 = CFrame.new(0,1,0)
RLegGlue.F0 = Vector3.new(0.01,0.001,0)
RLegGlue.F1 = Vector3.new(-0.01,0.01,0)
RLegGlue.F2 = Vector3.new(0.01,-0.01,0)
RLegGlue.F3 = Vector3.new(-0.01,-0.01,0)
local RLegCollision = Instance.new("Part",Character)
RLegCollision.TopSurface, RLegCollision.BottomSurface = Enum.SurfaceType.Smooth, Enum.SurfaceType.Smooth
RLegCollision.formFactor = Enum.FormFactor.Custom
RLegCollision.Size, RLegCollision.Transparency = Vector3.new(0.9,0.9,0.9), 1
local RArmWeld = Instance.new("Weld",RLegCollision)
RArmWeld.Part0, RArmWeld.Part1 = RLeg, RLegCollision
local RLegWeld = Instance.new("Weld",RLeg)
RLegWeld.Part0, RLegWeld.Part1 = LLeg, RLeg
RLegWeld.C0 = CFrame.new(1,0,0)
Head.Velocity = Head.Velocity + Vector3.new(math.random(-50,50), 0, math.random(-50,50))
game.ReplicatedStorage.SetCamera:FireClient(Player, PlayerName)
end
-------------------------------------------------------------------------------------------------------------------------------------
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
HandleCharacterDeath(Player, Character, Character:WaitForChild("Humanoid", 10))
end)
end)