i have made a script where if a player dies, he gets the dead body duplicated and it stays in the world forever. However i do want to add a ragdoll to this but i don’t exactly know how…
Could anyone tell me how?
Thanks alot!
oh and heres the script btw
local players = game:GetService("Players")
local function makeDup(char)
char.Archivable = true
local dChar = char:Clone()
char.Archivable = false
dChar.Parent = workspace
for i, v in pairs(char:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Anchored = true
v.Transparency = 1
end
end
local healthScript = dChar:FindFirstChild("Health")
if healthScript then
healthScript.Enabled = false
end
end
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
hum.Died:Connect(function()
print("Player Has Died!", player.Name)
makeDup(char)
end)
end)
end)
Sure. Since the ragdoll is on the server’s side, you can place it in the same script (under serverscriptstorage) if you want.
Here is an example:
local players = game:GetService("Players")
local function makeRagDoll(doll)
for index, joint in pairs (doll:GetDescendants()) do
-- insert rest of code
end
end
local function makeDup(char)
char.Archivable = true
local dChar = char:Clone()
char.Archivable = false
dChar.Parent = workspace
for i, v in pairs(char:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Anchored = true
v.Transparency = 1
end
end
local healthScript = dChar:FindFirstChild("Health")
if healthScript then
healthScript.Enabled = false
end
if dChar then
makeRagDoll(dChar)
else
warn("No Character Duplicate!")
end
end
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
hum.Died:Connect(function()
print("Player Has Died!", player.Name)
makeDup(char)
end)
end)
end)
okay let me clarify myself, you wrote the code of the character getting duplicated, and there where you wrote – paste the rest here is where the ragdoll script should go? Sorry if im a bit dumb considering the script was mostly followed by a tutorial :pp
Yes, exactly. But here is the full script. I have tested it out in studio, it works.
local players = game:GetService("Players")
local function makeRagDoll(doll)
for index, joint in pairs (doll:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
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:Destroy()
end
end
end
local function makeDup(char)
char.Archivable = true
local dChar = char:Clone()
char.Archivable = false
dChar.Parent = workspace
for i, v in pairs(char:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Anchored = true
v.Transparency = 1
end
end
local healthScript = dChar:FindFirstChild("Health")
if healthScript then
healthScript.Enabled = false
end
if dChar then
makeRagDoll(dChar)
else
warn("No Character Duplicate!")
end
end
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
hum.Died:Connect(function()
print("Player Has Died!", player.Name)
makeDup(char)
end)
end)
end)
one last question. did you name the script anything else? and if so where did you place it? Cause like i mentioned it was in serverscriptservice, again thanks alot for helping me out!
Ok, it seems like the problem is that the player is ragdolled on the server side, but is not ragdolled on the local client side for some reason. I have linked 2 helpful posts.
The first post is someone else with the same problem, and the second post is someone else fixing it.
Yea, some of these could work, but i found out that thats not the real problem, its whenever i touch the dead players body, he stands up and spins around slowly…