Heya!
Just recently I’ve been at work on this Ragdoll script for a personal project I’m working on. The general effect of turning the player into a ragdoll works fine… but, here’s the problem.
When the player turns into a ragdoll upon death, I want the corpse to be preserved within a model during the round (morbidly for comedic purposes). It’s been a battle between GetChildren() and GetDescendants(), and as I managed to get all the parts together, here was the outcome:
It appears that when the model is being preserved and replicated over into another model in the workspace, only one of the accessories are replicated while the rest are not. Why is that, and what can I do to fix it?
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.BreakJointsOnDeath = false
character.Humanoid.Died:Connect(function()
local newGroup = Instance.new("Model")
newGroup.Parent = game.Workspace.CorpseGroup
newGroup.Name = player.Name
-- Create ragdoll
for _, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") then
local a0,a1 = Instance.new("Attachment"),Instance.new("Attachment")
a0.CFrame = v.C0
a1.CFrame = v.C1
a0.Parent = v.Part0
a1.Parent = v.Part1
local b = Instance.new("BallSocketConstraint")
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = v.Part0
v:Destroy()
end
end
wait()
-- Problem begins here
--replicating parts
if not character:FindFirstChild("Shirt") then
print("No shirt")
else
character:WaitForChild("Shirt").Parent = newGroup
end
if not character:FindFirstChild("Pants") then
print("No pants")
else
character:WaitForChild("Pants").Parent = newGroup
end
for _,v in pairs(character:GetChildren()) do
if v:IsA("Part") then
v.Parent = newGroup
end
end
local humanoid = character.Humanoid
humanoid.Parent = newGroup
end)
Another solution I’ve tried is adding an:
or v:IsA("Accessory")
But the outcome of just adding that little piece itself is no accessories being shown on the character at all.
AGAIN, the ragdoll script works fine. I’m just having a troubling time replicated all the accessories into a model and I was hoping if anybody could offer any ideas/assistance on how I can solve this issue.