Detain Tool Fix

I have a detain tool, that functions fully, other than bringing players back and detaining them if they reset, the person who is Detaining the other one, will always survive the first reset, but for some reason. they don’t survive the 2nd reset…

I have looked at many different similar problems, and I tried to use AlignPosition, and AlignOrientation, and I still don’t understand them enough, I even have turned off BreakJointsOnDeath as a test.

here is a little bit of the code around where they should be breaking away from me before death

while DetainActive.Value == 1 do
					wait()
					if ThreeDimensions.Humanoid.Health <= 10 then
						Weld:Destroy()
						wait()
						ServerPlr.CharacterAdded:Connect(function(Plr)
							if Plr.Name == ServerPlr.Name then
								wait()
								Plr.Humanoid.BreakJointsOnDeath = false
								Plr.Humanoid.PlatformStand = true
								Plr.HumanoidRootPart.CFrame = Tool.CFrame + Tool.CFrame.LookVector * DistanceMultiplier.Value
								local NewWeld = Instance.new("WeldConstraint")
								NewWeld.Parent = Tool
								print(NewWeld.Parent)
								NewWeld.Part0 = Plr.HumanoidRootPart
								NewWeld.Part1 = Tool
								local Parts = Plr:GetDescendants()
								for i, v in pairs(Parts) do
									if v:IsA("BasePart") then
										v.Massless = true
									end
								end
								if ThreeDimensions.Humanoid.Health <= 15 then
									Weld:Destroy()
								end
							end
						end)
					end
				end

This bit of script is responsible for, if they are about die, breaking the weld. and making myself not die. it always works the first time, and then the 2nd part of the script is responsible for Detaining them upon respawning, but if they die this time, it kills both of us