Help with limb dismemberment

I made a script so when the players health reaches less than 15, and the player gets hit by a weapon, the players head will fall off via cloning the players head and making the original head invisible. The problem is, when the players head gets cloned, the accessories on the player stay on the invisible head and don’t carry over to the cloned head. How can I fix this?

3 Likes

btw here is the script, its inside a weapon:

function onTouched(hit)
local human = hit.Parent:findFirstChild(“Humanoid”)
if (human ~= nil) then
if human.Health < 15 then
local HeadOff = human.Parent.Head:Clone()
HeadOff.Parent = game.Workspace
HeadOff.CFrame = human.Parent.Head.CFrame
HeadOff.CanCollide = true
HeadOff.Anchored = false
for i, v in pairs(human.Parent:GetDescendants()) do
if v:IsA(“Part”) and v.Name == “Head” then
v.Transparency = 1
end
end
game.Debris:AddItem(HeadOff, 10)
end

The reason for this happening, is because you only cloned the head itself and not the accessories. If you wish to clone the accessories and remove the ones on the invisible head. Simply do so by adding this to your code.

for i,n in pairs (script.Parent:GetDescendants())do
if n:IsA("Accessory")then
	local newV = n:Clone()
	local w = Instance.new("ManualWeld")
	w.Part0 = newV
	w.Part1 = V
	wait(.1)
	n:Destroy()
end
end

If this doesn’t work, you may also try using regular welds on the accessories. Small typo sorry

2 Likes

Thank you for the response, I will try this!

Hmm, seems its not working. Maybe I put it in the wrong place, im getting this error in the output:

“Expected BasePart got Accessory for ManualWeld:Part0.”

Yeah I just realized that the weld needs to be attached to a part. Therefore it would be

w.Part0 = newV.Handle
w.Part1 = v

It fixes the output error, but now the accessories are completely invisible. What about using attachments maybe?

Maybe it has something to do with this ragdoll script im using

for i,n in pairs (script.Parent:GetDescendants())do
if n:IsA(“Accessory”)then
n.Transparency = 0
local newV = n:Clone()
local w = Instance.new(“ManualWeld”)
w.Part0 = newV.Handle
w.Part1 = v
wait(.1)
n:Destroy()
end
end

i just added a line to [123SuperSonicYT2]'s code

Still not working, I dont understand what im doing wrong.