Hello! I am most new to scripting and I want to modify my ragdoll script to create a clone of the player as like a “dead body” that stays there permanently even the the player respawns. I have tried many ways but I am unable to get it working.
Here is the code I have made so far: (there is no errors in this script)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
Character.Humanoid.BreakJointsOnDeath = false
Character.Humanoid.Died:Connect(function()
local humanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local torso = Character:WaitForChild("Torso")
local head = Character:WaitForChild("Head")
local leftArm = Character:WaitForChild("Left Arm")
local rightArm = Character:WaitForChild("Right Arm")
local leftLeg = Character:WaitForChild("Left Leg")
local rightLeg = Character:WaitForChild("Right Leg")
-- Set collision properties
head.CanCollide = true
leftArm.CanCollide = true
rightArm.CanCollide = true
leftLeg.CanCollide = true
rightLeg.CanCollide = true
torso.CanCollide = true
humanoidRootPart.CanCollide = false
for _, v in pairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
local Attachment0, Attachment1 = Instance.new("Attachment"), Instance.new("Attachment")
Attachment0.CFrame = v.C0
Attachment1.CFrame = v.C1
Attachment0.Parent = v.Part0
Attachment1.Parent = v.Part1
local BallSocketConstraint = Instance.new("BallSocketConstraint")
BallSocketConstraint.Attachment0 = Attachment0
BallSocketConstraint.Attachment1 = Attachment1
BallSocketConstraint.Parent = v.Parent
v:Destroy()
end
end
end)
end)
end)
Thanks