Player died after killing enemy

it dies after welding enemy


local function OnHitJob(target,char)
	if target ~= nil then
		local x = math.random(1,2)
		if x == 1 then
			Sounds.HardHit1:Play()
		else
			Sounds.HardHit2:Play()
		end
		target:FindFirstChild("Humanoid"):TakeDamage(35)
		
		for i,v in pairs(target:GetDescendants()) do
			if v:IsA("BasePart") then
				v.Massless = true
			end
		end
			
		local weld = Instance.new("WeldConstraint")
		target.HumanoidRootPart.CFrame = stand["Right Arm"].CFrame * CFrame.Angles(math.rad(-90),0,0)
		weld.Part0 = target.HumanoidRootPart
		weld.Part1 = stand["Right Arm"]
		weld.Parent = stand["Right Arm"]
		
		game.Debris:AddItem(weld,0.4)
		target.Archivable = true
	end
end

It does not appear you are checking if the target is the player using the attack. This means if the attack part(s) touches the player in the process of moving to the enemy, then the attacking player will take damage resulting in the player’s death.

1 Like

i recomend changing the Enemy’s Humanoids names to “Enemy” , that way you could just do

target:FindFirstChild("Enemy"):TakeDamage(35)

and since the player doesnt have a ‘Enemy’ it wont do damage