local w = Instance.new("Weld")
w.Part0 = x
w.Part1 = hit.Parent.UpperTorso
w.Parent = x
debris:AddItem(w,10)
I have this code in a touched function that does damage (damage emphasized for convenience) and for some reason whenever its used to kill or when the victim dies the user also dies
https://gyazo.com/2b9b847aaebf32c4dadd9ee2e211a9b5
(The weld is used to grab the player and hold him there, hence the use of a weld)
local x = Instance.new("Part")
x.CanCollide = false
x.Massless = true
x.Transparency = 1
x.Parent = workspace
debris:AddItem(x,10)
local hand = Instance.new("Weld")
hand.Part0 = rib.RightHand
hand.Part1 = x
hand.Parent = x
x.Touched:connect(function(hit)
if hit.Parent ~= nil and hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent:FindFirstChild("Humanoid") ~= pchar.Humanoid and debounce == false then
debounce = true
if hit.Parent.Humanoid.Health > 10 then
hit.Parent.Humanoid:TakeDamage(100)
elseif hit.Parent.Humanoid.Health <= 10 then
hit.Parent.Humanoid:TakeDamage(hit.Parent.Humanoid.Health-1)
end
local w = Instance.new("Weld")
w.Part0 = x
w.Part1 = hit.Parent.UpperTorso
w.Parent = x
debris:AddItem(w,10)
for i,v in pairs(workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("Humanoid") ~= nil and v:FindFirstChild("Humanoid") ~= pchar.Humanoid and hit.Parent.Name == v.Name then
for i, object in pairs(v:GetChildren()) do
if object:IsA("BasePart") then
object.Massless = true
object.CanCollide = false
end
end
end
end
wait(10)
debounce = false
end
end)

2 comments
you gotta provide a little more code in order for anyone to know why it's happening. the weld doesn't help at all. nice work, by the way.
i tried changing every piece of the code and nothing changed until i deleted the weld