Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Problem with a stealth attack killing both players?

I made a kill-from-behind script that welds yourself to the victim. The problem is, that after I make the victim die, the person welded to him dies as well! I even made sure the weld was destroyed before killing the victim. Here is my script:

	mouse = plr:GetMouse()
	target = mouse.Target
	local backweld = Instance.new("Weld",plr.Character.Torso")
	backweld.Part0 = plr.Character.Torso
	backweld.Part1 = target.Parent.Torso
	backweld.C0 = CFrame.new(0,0,-1)
	game.Debris:AddItem(target.Parent.Torso,5)
	game.Debris:AddItem(backweld, 1.5)
			
			
	wait(1.5)
			
	wait(1)
	target.Parent.Humanoid.Health = 0

1 answer

✓ Accepted answer

My only idea is that you need to swap the lines game.Debris:AddItem(target.Parent.Torso,5) and game.Debris:AddItem(backweld, 1.5). My reasoning for this is my belief that the intvalue after the location/name of the block/weld is a wait time. Am I correct on that? Anyways, moving the second line behind the first is my most likely solution to fixing your problem.

Fixed Code:

mouse = plr:GetMouse()
target = mouse.Target
local backweld = Instance.new("Weld",plr.Character.Torso")
backweld.Part0 = plr.Character.Torso
backweld.Part1 = target.Parent.Torso
backweld.C0 = CFrame.new(0,0,-1)
game.Debris:AddItem(backweld, 1.5)
game.Debris:AddItem(target.Parent.Torso,5)


wait(1.5)

wait(1)
target.Parent.Humanoid.Health = 0

This discussion is preserved as it was. New answers, comments, and votes are closed.