Hello everyone,
Im trying to break the welds of my model when its humanoid dies. However, my original script did not work so I tried different solutions and ended up making it a lot simpler. Although I’ve made these changes it still doesn’t work and it shows no errors in the output. Im really not sure on what I should do next, but any help will be greatly appreciated, thank you.
local model = script.Parent
local hum = model.Humanoid
hum.Died:Connect(function()
for i,v in model do
print(v)
end
end)```
local model = script.Parent
local hum = model.Humanoid
hum.Died:Connect(function()
print("Reset")
for _, child in model:GetChildren() do
if child:IsA("BasePart") or child:IsA("MeshPart") then
print(child)
if child:FindFirstChildWhichIsA("Attachment") then
print("Found attachment in", child)
else
print("No attachment in", child)
end
end
end
end)
Hey, thank you so much!!
This solves my problem and now my code is working perfectly. I also found out that I needed a torso in order for Humanoid.Died to work. Here is the code below, thank you so much again for your help.
local model = script.Parent
local hum = model.Humanoid
local anchPart = model.AnchoredPart --part which all other parts are welded to
local debris = game:GetService(“Debris”)
hum.Died:Connect(function() --hum.died must have a torso in order to work
print(“YES YES YES”)
for _, child in model:GetChildren() do
print(child)
local c = child:FindFirstChildWhichIsA(“WeldConstraint”)
if c then
print(“found WeldConstraint in”, child)
debris:AddItem(c, 2)
debris:AddItem(anchPart, 2)
end
end
end)